D
dejoy
Unregistered / Unconfirmed
GUEST, unregistred user!
我在做一个Delphi7的绿色版,用Inno setup 来做了一个绿化注册程序(初学),想在注册的时候把delphi的目录添加到系统环境变量path中,不重启立即生效.倒是找到相关的代码,不过是delphi的,没法在inno setup script中运行. 特请教对Inno setup script 熟悉的达人.
下面是我的CODE段代码:
var
FRootDir: string;
procedure _SetDelphiPath(aIsInstall: Boolean);
var
S_Path, s: string;
S1: string;
begin
if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SYSTEM/CurrentControlSet/Control/Session Manager/Environment', 'Path', S_Path) then
begin
if aIsInstall then
S1 := ExpandConstant('{src}/bin')
else
S1 := FRootDir + '/bin';
if pos(Uppercase(S1), Uppercase(S_Path)) = 0 then //还没有加入
begin
if aIsInstall then
begin
S_Path := S_Path + ';' + S1;
end;
end else
if not aIsInstall then
begin
StringChangeEx(S_Path, S1 + ';', '', True);
StringChangeEx(S_Path, S1, '', True);
end;
if aIsInstall then
S1 := ExpandConstant('{src}/Projects/bpl')
else
S1 := FRootDir + '/Projects/bpl';
if pos(Uppercase(S1), Uppercase(S_Path)) = 0 then //还没有加入
begin
if aIsInstall then
begin
S_Path := S_Path + ';' + S1;
end;
end else
if not aIsInstall then
begin
StringChangeEx(S_Path, S1 + ';', '', True);
StringChangeEx(S_Path, S1, '', True);
end;
RegWriteStringValue(HKEY_LOCAL_MACHINE, 'SYSTEM/CurrentControlSet/Control/Session Manager/Environment', 'Path', S_Path);
end;
end;
procedure DeinitializeUninstall();
begin
_SetDelphiPath(False);
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
FIsExists := False;
if CurUninstallStep = usUninstall then
begin
if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE/Borland/Delphi/7.0', 'RootDir', FRootDir) then
begin
StringChangeEx(FRootDir, '//', '/', True);
FRootDir := RemoveBackslash(FRootDir);
end;
end;
end;
procedure CurPageChanged(CurPageID: Integer);
var
SL: TStringList;
S1: string;
begin
if CurPageID = wpFinished then
begin
_SetDelphiPath(True);
[blue]//问题在下面的代码如何实现:
//SendMessage(HWND_BROADCAST,WM_SETTINGCHANGE,0,Integer(Pchar('Environment')));
//这是我找到的delphi里的方法,在inno setup script里该怎么写?或是有其它的方法?[/blue]
end;
end;
inno setup 中貌似有一个ChangesEnvironment属性,已经设为true,不过似乎不起作用,新建一个DOS窗口后查看Path还是没添加的.
Inno setup 肯定是能做到的,因为Delphi 7 Second Edition v7.2安装程序也是用它做的,它的安装完成后系统变量就立即生效了,但没它的inno script,不知是如何做的.
下面是我的CODE段代码:
var
FRootDir: string;
procedure _SetDelphiPath(aIsInstall: Boolean);
var
S_Path, s: string;
S1: string;
begin
if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SYSTEM/CurrentControlSet/Control/Session Manager/Environment', 'Path', S_Path) then
begin
if aIsInstall then
S1 := ExpandConstant('{src}/bin')
else
S1 := FRootDir + '/bin';
if pos(Uppercase(S1), Uppercase(S_Path)) = 0 then //还没有加入
begin
if aIsInstall then
begin
S_Path := S_Path + ';' + S1;
end;
end else
if not aIsInstall then
begin
StringChangeEx(S_Path, S1 + ';', '', True);
StringChangeEx(S_Path, S1, '', True);
end;
if aIsInstall then
S1 := ExpandConstant('{src}/Projects/bpl')
else
S1 := FRootDir + '/Projects/bpl';
if pos(Uppercase(S1), Uppercase(S_Path)) = 0 then //还没有加入
begin
if aIsInstall then
begin
S_Path := S_Path + ';' + S1;
end;
end else
if not aIsInstall then
begin
StringChangeEx(S_Path, S1 + ';', '', True);
StringChangeEx(S_Path, S1, '', True);
end;
RegWriteStringValue(HKEY_LOCAL_MACHINE, 'SYSTEM/CurrentControlSet/Control/Session Manager/Environment', 'Path', S_Path);
end;
end;
procedure DeinitializeUninstall();
begin
_SetDelphiPath(False);
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
FIsExists := False;
if CurUninstallStep = usUninstall then
begin
if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE/Borland/Delphi/7.0', 'RootDir', FRootDir) then
begin
StringChangeEx(FRootDir, '//', '/', True);
FRootDir := RemoveBackslash(FRootDir);
end;
end;
end;
procedure CurPageChanged(CurPageID: Integer);
var
SL: TStringList;
S1: string;
begin
if CurPageID = wpFinished then
begin
_SetDelphiPath(True);
[blue]//问题在下面的代码如何实现:
//SendMessage(HWND_BROADCAST,WM_SETTINGCHANGE,0,Integer(Pchar('Environment')));
//这是我找到的delphi里的方法,在inno setup script里该怎么写?或是有其它的方法?[/blue]
end;
end;
inno setup 中貌似有一个ChangesEnvironment属性,已经设为true,不过似乎不起作用,新建一个DOS窗口后查看Path还是没添加的.
Inno setup 肯定是能做到的,因为Delphi 7 Second Edition v7.2安装程序也是用它做的,它的安装完成后系统变量就立即生效了,但没它的inno script,不知是如何做的.