在更改环境值后,Innosetup SendMessage [英] Innosetup SendMessage after changing the environment values
问题描述
我使用InnoSetup在注册表中设置环境变量:
I set environment variable in the registry using InnoSetup:
[Registry]
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: string; ValueName: "MY_PROGRAM_HOME_DIR"; ValueData: "{app}"
但是系统在调用 SendMessage
。
[Code]
procedure DeinitializeSetup();
begin
// HWND_BROADCAST = $FFFF
// WM_SETTINGCHANGE = $001A
SendMessage($FFFF, $001A, 0, Longint(PChar('Environment')));
end;
InnoSetup说:
InnoSetup says:
... Column 60:Type mismatch
... Column 60: Type mismatch
如何正确类型转换 PChar
到InnoSetup脚本中的 Longint
中?
How do I correctly typecast PChar
into Longint
in InnoSetup script?
推荐答案
ChangesEnvironment
指令而不是从你的脚本代码做同样的。从引用:
Use the ChangesEnvironment
directive instead of doing the same from your script code. From the reference:
设置为yes时,在安装结束时安装程序将通知
其他正在运行的应用程序
When set to yes, at the end of the installation Setup will notify other running applications (notably Windows Explorer) that they should reload their environment variables from the registry.
在InnoSetup中,当您使用上述指令时,以下代码在里面调用:
In InnoSetup, when you use the above directive, the following code is called inside:
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0,
LPARAM(PChar('Environment')), SMTO_ABORTIFHUNG, 5000, MsgResult);
这篇关于在更改环境值后,Innosetup SendMessage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!