with RegistrySecurity(HKLM\SYSTEM\ControlSet001\Enum\Root\LEGACY_DMLOAD) do
ProtectedDAcl := false;
if DAcl.DeleteItems(Everyone) then
But only modifying this permission and not deleting my key..
I'll use some to clean some keys after uninstall my program
I'm a bit confused. Your code first adds access for Everyone and then removes it again. Is that intentional? What purpose does that have?
Anyway, the code you're using should more or less work, as long as you have enough privileges to change the ACL. You may have to take ownership first if all else fails. One thing: I'm not sure right now which exact syntax you have to use when feeding a registry path into "RegistrySecurity". It might be safer to call RegOpen/CreateKeyEx() yourself and feed the resulting HKEY into RegistrySecurity.