I would like to set a registry key to HKLM when user is an administrator or HKCU when user is a normal user.
I tried this:
[Registry]
Root: "{code:DefRegRoot}"; Subkey: "Software\MyCompany\MySW\Settings"; ValueType: string; ValueName: "InstallPath"; ValueData: "{app}"
[Code]
function IsRegularUser(): Boolean;
begin
Result := not (IsAdminLoggedOn or IsPowerUserLoggedOn);
end;
function DefRegRoot(Param: String): String;
begin
if IsRegularUser then
Result := HKCU
else
Result := HKLM;
end;
But the compiler returns an error on the first Registry line:
Parameter "Root" is not a valid value.
Any suggestion about this ?
PrivilegesRequiredis fixed at compile time, there is no point trying to make a single installer do both per-machine and per-user installs. Pick one yourself and run with it. - MiralPrivilegesRequireddirective set to? By default your setup will never have run as a non admin user, and if a non admin user tries to run it, then your settings will be saved for the user they elevate to. - Deanna