Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>@WarmBooter, you can use the <a href="http://msdn.microsoft.com/en-us/library/aa363855%28VS.85%29.aspx" rel="nofollow noreferrer">CreateDirectory</a> function to accomplish this task.</p> <p>see this example :</p> <pre><code>program Project645; {$APPTYPE CONSOLE} uses AccCtrl, AclApi, Windows, SysUtils; type PTrusteeW = ^TTrusteeW; TTrusteeW = record pMultipleTrustee: PTrusteeW; MultipleTrusteeOperation: DWORD; { MULTIPLE_TRUSTEE_OPERATION } TrusteeForm: DWORD; { TRUSTEE_FORM } TrusteeType: DWORD; { TRUSTEE_TYPE } ptstrName: PWideChar; end; TExplicitAccessW = record grfAccessPermissions: DWORD; grfAccessMode: DWORD; { ACCESS_MODE } grfInheritance: DWORD; Trustee: TTrusteeW; end; Function CreateDirectoryFullAccess(NewDirectory:String) :Boolean; var SecurityAttributes : TSecurityAttributes; SecurityDescriptor : PSecurityDescriptor; ExplicitAccess : array[0..0] of TExplicitAccessW; easize : integer; pACL : Windows.PACL; begin ExplicitAccess[0].grfAccessPermissions:= STANDARD_RIGHTS_ALL or SPECIFIC_RIGHTS_ALL; ExplicitAccess[0].grfAccessMode:=Ord(SET_ACCESS); ExplicitAccess[0].grfInheritance:=SUB_CONTAINERS_AND_OBJECTS_INHERIT; ExplicitAccess[0].Trustee.TrusteeForm:=Ord(TRUSTEE_IS_NAME); ExplicitAccess[0].Trustee.TrusteeType:=Ord(TRUSTEE_IS_USER); ExplicitAccess[0].Trustee.ptstrName:='Everyone';//Access for all users SetEntriesinAclW(1,@ExplicitAccess,nil,pACL);//creates a new access control list //SecurityDescriptor:= AllocMem(Sizeof(SECURITY_DESCRIPTOR_MIN_LENGTH)); SecurityDescriptor:= AllocMem(SECURITY_DESCRIPTOR_MIN_LENGTH); InitializeSecurityDescriptor(SecurityDescriptor,SECURITY_DESCRIPTOR_REVISION); SetSecurityDescriptorDacl(SecurityDescriptor,true,pacl,false);//sets information in a discretionary access control list (DACL). FillChar(SecurityAttributes,sizeof(SECURITY_ATTRIBUTES),#0); SecurityAttributes.nLength:=sizeof(SECURITY_ATTRIBUTES); SecurityAttributes.lpSecurityDescriptor:=SecurityDescriptor; SecurityAttributes.bInheritHandle:=false; CreateDirectory(PChar(NewDirectory),@SecurityAttributes); Result:=GetLastError=0;// if all ok, GetLastError = 0 end; begin if CreateDirectoryFullAccess('C:\MyNewDir') then Writeln('Ok') else Writeln('Failed'); Readln; end. </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload