Jaymol
asked on
Security Permissions on NT4
How can I change the security permissions of a registry key on Windows NT4? I can do it within Regedt32.exe, but want to do it programatically from within Delphi.
If you can do it within Regedt32, you can use the TRegistry class
Hi Jaymol, maybe you should try this component. It is a replacement for TRegistry and may be excactly what you are looking for:
http://www.jgsoftware.com/files/djntreg.zip
Regards,
Epsylon.
http://www.jgsoftware.com/files/djntreg.zip
Regards,
Epsylon.
ASKER
Unfortunately, regedit and regedt32 are NOT the same program. Regedt32 allows changes on Security permissions whereas using regedit or TRegistry does not allow this. I am adept in manipulating the registry as far as entries go, but this is a matter not covered by the TRegistry class. If I am incorrect in this, then I would appreciate an example of how security permissions can be changed with TRegistry.
ASKER
Since submitting this question, I have found a route around the problem by opening "regedt32.exe" and sending keypresses to make the appropriate changes. But, if anyone can answer the question anyway, I would be very grateful.
ASKER
Can ANYONE answer this question successfully??????
Looked at SetNamedSecurityInfo. It is described in the win32.hlp file, but it is not in Delphi's help context. So you need to open win32.hlp file manually and look in the index for this function.
Regards, Madshi.
Regards, Madshi.
ASKER
Could you give me an example? I can't figure out how to use it properly.
Well, I didn't try it, but it should work like this:
// enum types in Delphi are commonly 1 byte long, in win32 API these types are mostly 4 bytes long, so we must switch the compiler settings
{$minenumsize 4}
type TObjType = (SE_UNKNOWN, SE_FILE, SE_SERVICE, SE_PRINTER, SE_REGISTRY, SE_LMSHARE, SE_KERNEL, SE_WINDOW);
{$minenumsize 1}
function SetNamedSecurityInfo(objNa me: PWideChar; objType: TObjType; SecInfo: dword; pSIDOwner,pSIDGroup: PSID; ppDacl,ppSacl: PACL) : dword; stdcall;
external 'advapi.dll' name 'SetNamedSecurityInfoW';
function AllowRegKeyForEveryone(key : hkey; path: string) : boolean;
case key of
HKEY_LOCAL_MACHINE : path:='MACHINE\' +path;
HKEY_CURRENT_USER : path:='CURRENT_USER\'+path ;
HKEY_CLASSES_ROOT : path:='CLASSES_ROOT\'+path ;
HKEY_USERS : path:='USERS\' +path;
end;
result:=SetNamedSecurityIn fo(pwidech ar(wideStr ing(path)) ,SE_REGIST RY_KEY,DAC L_SECURITY _INFORMATI ON,nil,nil ,nil,nil)= 0;
end;
if AllowRegKeyForEveryone(HKE Y_LOCAL_MA CHINE,'Sof tware') then ...
This example simply gives in a new nil dacl. A nil dacl means that everyone has access. If you want to give specific accesses to specific users, you'll have to create a custom dacl.
Regards, Madshi.
// enum types in Delphi are commonly 1 byte long, in win32 API these types are mostly 4 bytes long, so we must switch the compiler settings
{$minenumsize 4}
type TObjType = (SE_UNKNOWN, SE_FILE, SE_SERVICE, SE_PRINTER, SE_REGISTRY, SE_LMSHARE, SE_KERNEL, SE_WINDOW);
{$minenumsize 1}
function SetNamedSecurityInfo(objNa
external 'advapi.dll' name 'SetNamedSecurityInfoW';
function AllowRegKeyForEveryone(key
case key of
HKEY_LOCAL_MACHINE : path:='MACHINE\' +path;
HKEY_CURRENT_USER : path:='CURRENT_USER\'+path
HKEY_CLASSES_ROOT : path:='CLASSES_ROOT\'+path
HKEY_USERS : path:='USERS\' +path;
end;
result:=SetNamedSecurityIn
end;
if AllowRegKeyForEveryone(HKE
This example simply gives in a new nil dacl. A nil dacl means that everyone has access. If you want to give specific accesses to specific users, you'll have to create a custom dacl.
Regards, Madshi.
ASKER
Madshi, could you submit that as an answer? I wanna give you the points you deserve.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.