I am running my delphi application using ‘run as admin..’ by right clicking on the exe. This application has following code to insert into HKLM registry.
begin
kValue := 'testing';
Reg.CloseKey;
Reg.Free;
try
Reg := TRegistry.Create(KEY_READ OR KEY_WOW64_64KEY);
Reg.RootKey := HKEY_LOCAL_MACHINE;
Reg.OpenKey('SOFTWARE\explorev2', True);
Reg.WriteString('test', kValue);
Result := Reg.ReadString('test');
except
;
end;
I am getting exception ‘failed to set data for ‘test”; though the application is running with admin privileges. Can anybody help me out..?
You are creating the TRegistry object with read access only:
Create it with write access instead: