REGEDIT4
HKEY_LOCAL_MACHINE\Software\文心软件工作室]
@="文心工作室"
"姓名"="徐海斌"
"年龄"=hex:23
"婚否"=dword:00000000
一不做二不休,直接下载打开innosetup的代码,搜索Environment,果真找到了。
很简单:
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0,LPARAM("Environment"), SMTO_ABORTIFHUNG, 5000, &MsgResult);
For example, on Windows NT-based systems, the following code fragment should propagate the changes to the environment variables used in the Command Prompt:
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM) "Environment", SMTO_ABORTIFHUNG, 5000, &dwReturnValue); None of the applications that ship with Windows 95 and Windows 98, including Windows Explorer and Program Manager, respond to this message. Thus, while this article can technically be implemented on Windows 95 and Windows 98, there is no effect except to notify third-party applications. The only method of changing global environment variables on Windows 95 is to modify the autoexec.bat file and reboot.
谢谢,已解决,不用重新编译的版本.自己编译很麻烦吧? 貌似原版都不支持sysutils里的好多函数. 原来是没有在正确的inno事件中调用. 方法设置ChangesEnvironment后,需要在正确的事件中调用,安装时需要在以下调用 procedure CurStepChanged(CurStep: TSetupStep); begin if CurStep = ssInstall then _SetDelphiPath(True); end; 卸载时需要在以下调用: procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); begin if CurUninstallStep = usUninstall then begin _SetDelphiPath(False); end; end; 之前的 procedure CurPageChanged(CurPageID: Integer); begin if CurPageID = wpFinished then ..... 调用时inno已经通知刷新系统变量了,所以不起作用.要在通知刷新之前调用,经过试验前面两个事件时机结果正确.