Quantcast
Channel: Delphi Forum - Delphi Programming Kings of Code - Delphi Programming
Viewing all articles
Browse latest Browse all 173

Access Violation Trying to modify folder's permissions

$
0
0
Hello guys,
I'm trying to make a little bit of code to create a folder and allow everyone modify access to the folder and its sub-directories. So far I have this code here :Code:
PHP Code:
unit ModifyPerms;

interface

uses
  Windows
MessagesSysUtilsClassesGraphicsControlsFormsDialogs,
  
StdCtrlsAccCtrlperms;

type
  TForm1 
= class(TForm)
    
Button1TButton;
    
procedure Button1Click(SenderTObject);

  private
    { Private 
declarations }
  public
    { Public 
declarations }
  
end;

var
  
Form1TForm1;

implementation
{$R *.DFM}

procedure TForm1.Button1Click(SenderTObject);
var
  
NewDaclOldDaclPACl;
  
SDPSECURITY_DESCRIPTOR;
  
EAPEXPLICIT_ACCESS_A;
begin
  GetNamedSecurityInfo
(PChar('c:\test'), SE_FILE_OBJECT,
DACL_SECURITY_INFORMATIONnilnil, @OldDaclnilSD);

  
BuildExplicitAccessWithName(@EAPChar('Everyone'), GENERIC_ALL,
GRANT_ACCESSSUB_CONTAINERS_AND_OBJECTS_INHERIT);

  
SetEntriesInAcl(1, @EAOldDaclNewDacl);

  
SetNamedSecurityInfo(PChar('c:\test'), SE_FILE_OBJECT,
DACL_SECURITY_INFORMATIONnilnilNewDaclnil);
end;

end
I'm using Delphi 5 (I know it's old as crap, no I can't just upgrade to a newer Delphi). When I run it tells me "Project ModifyPermissions.exe raised exception class EAccessViolation with message 'Access violation at address 00000001. Read of address 00000001'. Process stopped. Use Step or Run to continue.

I tried running the program in admin mode, it doesn't change anything. I'm confused since I got this code from someone who's program was working... Any help would be appreciated, thanks in advance! İmage

Viewing all articles
Browse latest Browse all 173

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>