Inno Setup 在继续之前检查是否安装了 WAMP
Inno Setup check if WAMP is installed before proceeding
我正在使用 Inno Setup 创建我们的安装向导,其中包含 WAMP 安装。但根据其他人的说法,双重 WAMP 安装会损害 WAMP 本身。所以我需要在继续之前检查是否安装了 WAMP。有什么方法可以做到这一点?
我能想到的检查程序是否已安装的唯一方法是检查它们的默认路径和其他可能的路径是否有它们的文件夹。
if DirExists('C:\wamp')
or DirExists('C:\wamp64')
or DirExists('C:\Program Files\wamp')
or DirExists('C:\Program Files\wamp64')
or DirExists('C:\Program Files(x86)\wamp')
or DirExists('C:\Program Files(x86)\wamp64')
or DirExists('{userdocs}\wamp')
or DirExists('{userdocs}\wamp64')
or DirExists('{userdocs}\Desktop\wamp')
or DirExists('{userdocs}\Desktop\wamp64')
then begin
MsgBox('An installation of WAMP was found.' + #13#10#13#10 + 'Please uninstall any WAMP/XAMPP programs first' + #13#10 + 'or install SpinShot in a different PC.', mbInformation, MB_OK);
Result := False;
end;
end;
WAMP 在安装过程中创建注册表项。安装程序基于 Inno Setup。
有 2 类 个注册表项:
1 个人:
[Registry]
Root: HKLM64; Subkey: "SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\";
ValueName: "{app}\wampmanager.exe"; ValueType: String; ValueData: "RUNASADMIN";
Check: "IsWin64"; MinVersion: 0.0,6.0; Flags: uninsdeletevalue uninsdeletekeyifempty
Root: HKLM32; Subkey: "SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\";
ValueName: "{app}\wampmanager.exe"; ValueType: String; ValueData: "RUNASADMIN";
Check: "Not IsWin64"; MinVersion: 0.0,6.0; Flags: uninsdeletevalue uninsdeletekeyifempty
2 默认卸载信息:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{wampserver64}_is1
路径在 InstallLocation
这允许我们检查是否安装了 WAMP 以及安装文件夹中是否存在可执行文件(作为附加检查)。
示例基于 64-bit
版本的 WAMP 3.0.6。
如果需要同时支持32- and 64-bit
两个版本,则需要进行调整。
[Setup]
ArchitecturesAllowed=x64
ArchitecturesInstallIn64BitMode=x64[
[Code]
function CheckWAMPExists(): Boolean;
var
sInstPath: String;
sInstallString: String;
begin
Result := False;
sInstPath := 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{wampserver64}_is1';
sInstallString := '';
if not RegQueryStringValue(HKLM, sInstPath, 'InstallLocation', sInstallString) then
RegQueryStringValue(HKCU, sInstPath, 'InstallLocation', sInstallString);
if sInstallString <> '' then begin
if FileExists(ExpandConstant(sInstallString) + 'wampmanager.exe') then
MsgBox('WAMP found!' + #13#10 + 'Install location:' + #13#10 + sInstallString
+ #13#10#13#10 + 'Installation will proceed!', mbInformation, MB_OK);
Result := True;
end
else begin
MsgBox('WAMP not found! Installation terminated.', mbInformation, MB_OK);
end;
end;
function InitializeSetup(): Boolean;
begin
Result := CheckWAMPExists;
end;
我正在使用 Inno Setup 创建我们的安装向导,其中包含 WAMP 安装。但根据其他人的说法,双重 WAMP 安装会损害 WAMP 本身。所以我需要在继续之前检查是否安装了 WAMP。有什么方法可以做到这一点?
我能想到的检查程序是否已安装的唯一方法是检查它们的默认路径和其他可能的路径是否有它们的文件夹。
if DirExists('C:\wamp')
or DirExists('C:\wamp64')
or DirExists('C:\Program Files\wamp')
or DirExists('C:\Program Files\wamp64')
or DirExists('C:\Program Files(x86)\wamp')
or DirExists('C:\Program Files(x86)\wamp64')
or DirExists('{userdocs}\wamp')
or DirExists('{userdocs}\wamp64')
or DirExists('{userdocs}\Desktop\wamp')
or DirExists('{userdocs}\Desktop\wamp64')
then begin
MsgBox('An installation of WAMP was found.' + #13#10#13#10 + 'Please uninstall any WAMP/XAMPP programs first' + #13#10 + 'or install SpinShot in a different PC.', mbInformation, MB_OK);
Result := False;
end;
end;
WAMP 在安装过程中创建注册表项。安装程序基于 Inno Setup。
有 2 类 个注册表项:
1 个人:
[Registry]
Root: HKLM64; Subkey: "SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\";
ValueName: "{app}\wampmanager.exe"; ValueType: String; ValueData: "RUNASADMIN";
Check: "IsWin64"; MinVersion: 0.0,6.0; Flags: uninsdeletevalue uninsdeletekeyifempty
Root: HKLM32; Subkey: "SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\";
ValueName: "{app}\wampmanager.exe"; ValueType: String; ValueData: "RUNASADMIN";
Check: "Not IsWin64"; MinVersion: 0.0,6.0; Flags: uninsdeletevalue uninsdeletekeyifempty
2 默认卸载信息:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{wampserver64}_is1
路径在 InstallLocation
这允许我们检查是否安装了 WAMP 以及安装文件夹中是否存在可执行文件(作为附加检查)。
示例基于 64-bit
版本的 WAMP 3.0.6。
如果需要同时支持32- and 64-bit
两个版本,则需要进行调整。
[Setup]
ArchitecturesAllowed=x64
ArchitecturesInstallIn64BitMode=x64[
[Code]
function CheckWAMPExists(): Boolean;
var
sInstPath: String;
sInstallString: String;
begin
Result := False;
sInstPath := 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{wampserver64}_is1';
sInstallString := '';
if not RegQueryStringValue(HKLM, sInstPath, 'InstallLocation', sInstallString) then
RegQueryStringValue(HKCU, sInstPath, 'InstallLocation', sInstallString);
if sInstallString <> '' then begin
if FileExists(ExpandConstant(sInstallString) + 'wampmanager.exe') then
MsgBox('WAMP found!' + #13#10 + 'Install location:' + #13#10 + sInstallString
+ #13#10#13#10 + 'Installation will proceed!', mbInformation, MB_OK);
Result := True;
end
else begin
MsgBox('WAMP not found! Installation terminated.', mbInformation, MB_OK);
end;
end;
function InitializeSetup(): Boolean;
begin
Result := CheckWAMPExists;
end;