(Co-Admin)
Registriert seit: 29. Mai 2002
Ort: Hamburg
11.116 Beiträge
Delphi 11 Alexandria
|
Re: Sicherheitseinstellungen von Dateien ändern
16. Aug 2003, 01:45
Moin Tpercon,
probier mal dies:
Delphi-Quellcode:
var
psd : PSECURITY_DESCRIPTOR;
dwLen : DWORD;
psdc : SECURITY_DESCRIPTOR_CONTROL;
dwDummy : DWORD;
begin
if not OpenDialog1.Execute then exit;
// erforderliche Buffergrösse ermitteln
dwLen := 0;
psd := nil;
GetFileSecurity(PChar(OpenDialog1.FileName),OWNER_SECURITY_INFORMATION,psd,0,dwLen);
// Security Descriptor auslesen
psd := AllocMem(dwLen);
try
if not GetFileSecurity(PChar(OpenDialog1.FileName),OWNER_SECURITY_INFORMATION,psd,dwLen,dwLen) then begin
ShowMessage(SysErrorMessage(GetLastError));
exit;
end;
GetSecurityDescriptorControl(psd,psdc,dwDummy);
Memo1.Lines.Clear;
if (psdc and SE_DACL_AUTO_INHERITED) = SE_DACL_AUTO_INHERITED then Memo1.Lines.Add('SE_DACL_AUTO_INHERITED');
if (psdc and SE_DACL_DEFAULTED) = SE_DACL_DEFAULTED then Memo1.Lines.Add('SE_DACL_DEFAULTED');
if (psdc and SE_DACL_PRESENT) = SE_DACL_PRESENT then Memo1.Lines.Add('SE_DACL_PRESENT');
if (psdc and SE_DACL_PROTECTED) = SE_DACL_PROTECTED then Memo1.Lines.Add('SE_DACL_PROTECTED');
if (psdc and SE_GROUP_DEFAULTED) = SE_GROUP_DEFAULTED then Memo1.Lines.Add('SE_GROUP_DEFAULTED');
if (psdc and SE_OWNER_DEFAULTED) = SE_OWNER_DEFAULTED then Memo1.Lines.Add('SE_OWNER_DEFAULTED');
if (psdc and SE_SACL_AUTO_INHERITED) = SE_SACL_AUTO_INHERITED then Memo1.Lines.Add('SE_SACL_AUTO_INHERITED');
if (psdc and SE_SACL_DEFAULTED) = SE_SACL_DEFAULTED then Memo1.Lines.Add('SE_SACL_DEFAULTED');
if (psdc and SE_SACL_PRESENT) = SE_SACL_PRESENT then Memo1.Lines.Add('SE_SACL_PRESENT');
if (psdc and SE_SACL_PROTECTED) = SE_SACL_PROTECTED then Memo1.Lines.Add('SE_SACL_PROTECTED');
if (psdc and SE_SELF_RELATIVE) = SE_SELF_RELATIVE then Memo1.Lines.Add('SE_SELF_RELATIVE');
finally
FreeMem(psd,dwLen);
end;
end;
Tschüss Chris
Die drei Feinde des Programmierers: Sonne, Frischluft und dieses unerträgliche Gebrüll der Vögel.
Der Klügere gibt solange nach bis er der Dumme ist
|
|
Zitat
|