home *** CD-ROM | disk | FTP | other *** search
- unit ShareProps;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, ExtCtrls, ComCtrls, CheckLst;
-
- type
- TpropShare = class(TFrame)
- pc: TPageControl;
- tsConns: TTabSheet;
- Panel4: TPanel;
- lvConns: TListView;
- tsGeneral: TTabSheet;
- Image1: TImage;
- Bevel1: TBevel;
- Bevel2: TBevel;
- Bevel3: TBevel;
- lPath: TLabel;
- lCur: TLabel;
- lMax: TLabel;
- lType: TLabel;
- lDesc: TLabel;
- stCur: TStaticText;
- stName: TEdit;
- stPath: TStaticText;
- stMax: TStaticText;
- stType: TStaticText;
- stDesc: TStaticText;
- bDiscon: TButton;
- lComment: TLabel;
- stComment: TStaticText;
- clbPerms: TCheckListBox;
- Label1: TLabel;
- procedure clbPermsClickCheck(Sender: TObject);
- procedure cmDiscon(Sender: TObject);
- private
- FShare: TObject;
- public
- property Share: TObject read FShare write FShare;
- procedure Refresh;
- end;
-
- implementation
-
- uses MiTeC_Shares, MiTeC_Routines, MiTeC_NetAPI32;
-
- {$R *.DFM}
-
- { TpropShare }
-
- procedure TpropShare.Refresh;
- var
- i,n: integer;
- begin
- pc.ActivePage:=tsGeneral;
- if IsNT then begin
- with PNTShareRecord(Share)^, TConnections.Create do begin
- stName.Text:=Name;
- stPath.Caption:=Path;
- stComment.Caption:=Comment;
- stType.Caption:=ShareTypes[ShareType];
- if MaxUserCount=uint(-1) then
- stMax.caption:='Unlimited'
- else
- stMax.Caption:=Format('%d',[MaxUserCount]);
- stCur.Caption:=Format('%d',[CurUserCount]);
- stDesc.Caption:=BoolToStr(SecurityDesc,True);
- for i:=0 to clbPerms.Items.Count -1 do
- clbPerms.Checked[i]:=TPermission(i) in Permissions;
- Qualifier:=Name;
- Refresh;
- n:=ConnectionCount;
- lvConns.Items.BeginUpdate;
- for i:=0 to n-1 do
- with lvConns.Items.Add, Connections[i]^ do begin
- Caption:=Name;
- SubItems.Add(Username);
- Subitems.Add(ShareTypes[ConnType]);
- SubItems.Add(Format('%d',[OpenFiles]));
- SubItems.Add(Format('%d',[Users]));
- SubItems.Add(FormatSeconds(Time,True,False,True));ImageIndex:=-1;
- end;
- lvConns.Items.EndUpdate;
- Free;
- end;
- end else begin
- end;
- end;
-
- procedure TpropShare.clbPermsClickCheck(Sender: TObject);
- var
- OCC: TNotifyEvent;
- idx: integer;
- p: TPoint;
- begin
- with TCheckListBox(Sender) do begin
- OCC:=OnClickCheck;
- OnClickCheck:=nil;
- GetCursorPos(p);
- p:=ScreenToClient(p);
- idx:=ItemAtPos(p,True);
- if idx>-1 then
- Checked[idx]:=not Checked[idx];
- OnClickCheck:=OCC;
- end;
- end;
-
- procedure TpropShare.cmDiscon(Sender: TObject);
- var
- Buf1,Buf2: array[0..256] of WideChar;
- n: DWORD;
- begin
- if (MessageDlg('Stop sharing?',mtConfirmation,[mbYes,mbNo],0)=mryes) then begin
- n:=NetShareDel(StringToWideChar(MachineName,Buf1,256),
- StringToWideChar(PNTShareRecord(Share)^.Name,Buf2,256),0);
- bDisCon.Enabled:=n<>ERROR_SUCCESS;
- if n<>ERROR_SUCCESS then
- raise Exception.Create(GetErrorMessage(n));
- end;
- end;
-
- end.
-