[英]Change Environment registry key based on whether installer in user or admin mode
If the user runs the installer in admin mode, the system path should be modified and if the installer is run in user mode, then the user environment variable need to me modified.如果用户以管理员模式运行安装程序,则应修改系统路径,如果安装程序以用户模式运行,则需要修改用户环境变量。
[Registry]
; If user installation mode
#define EnvironmentRootKey "HKCU"
#define EnvironmentKey "Environment"
; If admin mode
#define EnvironmentRootKey "HKLM"
#define EnvironmentKey "System\CurrentControlSet\Control\Session Manager\Environment"
Root: {#EnvironmentRootKey}; Subkey: "{#EnvironmentKey}"; ValueType: expandsz; \
ValueName: "Path"; ValueData: "{olddata};{app}\bin"; Tasks: addtopath; \
Check: NeedsAddPath(ExpandConstant('{app}\bin'))
I know HKA
automatically resolves to HKCU
if the installer is in user mode and HKLM
in admin mode, but there is no automatic equivalent for EnvironmentKey
.我知道如果安装程序处于用户模式而
HKLM
处于管理员模式, HKA
会自动解析为HKCU
,但是EnvironmentKey
没有自动等效项。
Basically something like:基本上是这样的:
#if "HKA" == "HKCU"
#define EnvironmentKey "Environment"
#else
#define EnvironmentKey "System\CurrentControlSet\Control\Session Manager\Environment"
#endif
Use a scripted constant :使用 脚本常量:
[Registry]
Root: HKA; Subkey: "{code:GetEnvironmentKey}"; ...
[Code]
function GetEnvironmentKey(Param: string): string;
begin
if IsAdminInstallMode then
Result := 'System\CurrentControlSet\Control\Session Manager\Environment'
else
Result := 'Environment';
end;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.