home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 April / Chip_2002-04_cd1.bin / zkuste / delphi / kolekce / d56 / NT.ZIP / Demos / FileSecurity / Unit1.pas < prev   
Pascal/Delphi Source File  |  2002-01-21  |  2KB  |  73 lines

  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.   Dialogs, NTFileSecurity, StdCtrls, Spin, IdGlobal;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Button1: TButton;
  12.     Button2: TButton;
  13.     Label5: TLabel;
  14.     SpinEdit1: TSpinEdit;
  15.     GroupBox1: TGroupBox;
  16.     Label1: TLabel;
  17.     Label2: TLabel;
  18.     Label3: TLabel;
  19.     Label4: TLabel;
  20.     Edit1: TEdit;
  21.     Edit2: TEdit;
  22.     Edit3: TEdit;
  23.     Edit4: TEdit;
  24.     OpenDialog1: TOpenDialog;
  25.     Label6: TLabel;
  26.     NTFileSecurity1: TNTFileSecurity;
  27.     procedure Button1Click(Sender: TObject);
  28.     procedure Button2Click(Sender: TObject);
  29.   private
  30.     { Private declarations }
  31.   public
  32.     { Public declarations }
  33.   end;
  34.  
  35. var
  36.   Form1: TForm1;
  37.  
  38. implementation
  39.  
  40. {$R *.dfm}
  41.  
  42. procedure TForm1.Button1Click(Sender: TObject);
  43. var AC:Integer;
  44. begin
  45.      If OpenDialog1.Execute Then
  46.      Begin
  47.           Label6.Caption:=ExtractFileName(OpenDialog1.FileName);
  48.           NTFileSecurity1.FileName:=OpenDialog1.FileName;
  49.           AC:=NTFileSecurity1.GetAceCount;
  50.           MessageBeep(MB_ICONINFORMATION);
  51.           Application.MessageBox(PChar('There are ' + IntToStr(AC) + ' ACE(s) In The ACL For This File...'),'NTTools',mb_OK + mb_ICONINFORMATION);
  52.           SpinEdit1.MaxValue:=AC-1;
  53.           Edit1.Text:=IntToStr(AC);
  54.      End;
  55. end;
  56.  
  57. procedure TForm1.Button2Click(Sender: TObject);
  58. var Ptr:Pointer;
  59. begin
  60.      Ptr:=NTFileSecurity1.GetFileAce(SpinEdit1.Value);
  61.      If Ptr=nil Then
  62.      Begin
  63.           MessageBeep(MB_ICONEXCLAMATION);
  64.           Application.MessageBox('Unable to retrieve ACE for file !','NTTools',mb_OK + mb_ICONEXCLAMATION);
  65.           Exit;
  66.      End;
  67.      Edit2.Text:=NTFileSecurity1.OwnerName;
  68.      Edit3.Text:=NTFileSecurity1.DomainName;
  69.      Edit4.Text:=IntToBin(NTFileSecurity1.AccessMask);
  70. end;
  71.  
  72. end.
  73.