Does anybody have example code of being able to fetch the ACL's of a file or directory using Delphi? I'm trying to work through the Microsoft SDK but the more I delve into it, the more confusing it's getting. I've managed to get this far but I don't know where to go from here.
ProcedureTForm1.GetPermissions(Path : String);
DaclPresent, DaclDefaulted : LongBool;
GetFileSecurity(PChar(Path), OWNER_SECURITY_INFORMATION or GROUP_SECURITY_INFORMATION or DACL_SECURITY_INFORMATION, nil, 0, SecDescSize);
SecDesc := GetMemory(SecDescSize);
if GetFileSecurity(PChar(Path), OWNER_SECURITY_INFORMATION or GROUP_SECURITY_INFORMATION or DACL_SECURITY_INFORMATION, SecDesc, SecDescSize, SecDescSize) then
If GetSecurityDescriptorDacl(SecDesc,DaclPresent,ACL,DaclDefaulted) Then
if DaclPresent then
// I don't know where to go from here!
// No Access to read security
I don't need to know who the owner of the file/directory is, nor do I need to modify the ACL's - I just want to see what the permisisons are - like if I was getting the output from ICACLS.
I could write a wrapper application to get the output of ICACLS and then get the information that way, but that's cheating, and will slow down my application a great deal. I want to use native API calls.
Google has not been helpful enough, everything I find is incomplete information.
Thanks in advance!