I just found this complete example project. It shows how to get the integrity label of a file/folder in Windows Vista.
Get Vista integrity label source.

  1. program IL;  
  2.  
  3. {$APPTYPE CONSOLE}  
  4.  
  5. uses
  6.   Dialogs,
  7.   JwaVista,
  8.   jwaWindows,
  9.   JwsclSecureObjects,
  10.   JwsclDescriptor,
  11.   JwsclMapping,
  12.   JwsclAcl,
  13.   JwsclTypes,
  14.   SysUtils;  
  15.  
  16. var Path : String;
  17.     IsDir : Boolean;
  18.     SD : TJwSecurityDescriptor;  
  19.  
  20.     H : HANDLE;
  21. begin
  22.   Path := ParamStr(1);
  23.   if not FileExists(Path) and not DirectoryExists(Path) then
  24.     exit;  
  25.  
  26.   IsDir := not FileExists(Path) and DirectoryExists(Path);  
  27.  
  28.   H := CreateFile(
  29.     PChar(Path),//LPCTSTR lpFileName,
  30.     STANDARD_RIGHTS_READ,//__in          DWORD dwDesiredAccess,
  31.     0,//__in          DWORD dwShareMode,
  32.     nil ,//__in          LPSECURITY_ATTRIBUTES lpSecurityAttributes,
  33.     OPEN_EXISTING,//__in          DWORD dwCreationDisposition,
  34.     FILE_FLAG_BACKUP_SEMANTICS,//__in          DWORD dwFlagsAndAttributes,
  35.     0//__in          HANDLE hTemplateFile
  36.   );  
  37.  
  38.   if H = INVALID_HANDLE_VALUE then
  39.     RaiseLastOSError;  
  40.  
  41.   try
  42.     {We could also directly use GetNamedSecurityInfo}
  43.     SD := TJwSecureGeneralObject.GetSecurityInfo(H,SE_FILE_OBJECT,
  44.        [siDaclSecurityInformation,siLabelSecurityInformation]);  
  45.  
  46.     if Assigned(SD) then
  47.     begin
  48.       if IsDir then
  49.         Writeln(SD.DACL.GetTextMap(TJwSecurityFileFolderMapping))
  50.       else
  51.         Writeln(SD.DACL.GetTextMap(TJwSecurityFileMapping));
  52.     end;  
  53.  
  54.     if SD.AuditACL.HasMandatoryLabel then
  55.       Writeln(SD.AuditACL.MandatoryLabel.SID.GetText);  
  56.  
  57.     SD.Free;
  58.   except
  59.     On E : Exception do
  60.       Writeln(E.Message);  
  61.  
  62.   end;  
  63.  
  64.   CloseHandle(H);  
  65.  
  66.   Writeln;
  67.   writeln(‘[Hit return]‘);
  68.   readln;
  69. end.

There is also a second way to get the integrity label.

  1. program MandatoryLabel;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6.   JwaWindows, JwaVista, JwsclSecureObjects, JwsclACL, JwsclTypes;
  7.  
  8. var F : TJwSecureFileObject;
  9.     aLabel : TJwSystemMandatoryAccessControlEntry;
  10. begin
  11.   F := TJwSecureFileObject.Create(‘C:\’);
  12.   try
  13.     aLabel := F.GetMandatoryLabel;
  14.     if Assigned(aLabel) then
  15.     begin
  16.       Writeln(aLabel.GetText());
  17.       if aLabel.GetMandatoryLevelType = MandatoryLevelHigh then
  18.         writeln(‘High integrity level’);
  19.       aLabel.Free;
  20.     end;
  21.   finally
  22.     F.Free;
  23.   end;
  24. end.
Send post as PDF to www.pdf24.org
convert this post to pdf.