I am working on windows service and i need to write registry HKCU keys on windows service mode but i know is not possible.
HKCU\Software\Microsoft\Windows\CurrentVer\Policies\Explorer\RestrictRun
I need to write this key, if i cant do that with windows service, how can i write to this key without admin rights? or is it possible?
Actually i can write this key on HKLM but it doesn't work on this key.
procedure CreatePolicy(AppName: string);
var
Reg: TRegistry;
Begin
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKey
('Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', True) then
Reg.WriteInteger('RestrictRun', 1);
if Reg.CreateKey('RestrictRun') then
if Reg.OpenKey('RestrictRun', True) then
Reg.WriteString(AppName, AppName);
except
Reg.CloseKey;
Reg.Free;
end;
Reg.CloseKey;
Reg.Free;
end
My Delphi version is XE7.