Inno Setup 检查安装VS2005运行环境

Inno Setup可以在程序安装时,通过检查注册表判断出VS2005运行环境是否已经安装[其他版本类似],如果没有安装,则将其安装。

#define MySourceDir "E:\MyAppSourceRoot"

[Files]
; VC Redistribute
Source: "{#MySourceDir}\vc2005redist\vcredist_x86.exe"; DestDir: "{tmp}"; Check: NeedInstallVC8SP1


[Code]
var
  vc8SP1Missing: Boolean;

function NeedInstallVC8SP1(): Boolean;
begin
  Result := vc8SP1Missing;
end;

function InitializeSetup(): Boolean;
begin
// 这里,不同版本运行环境对应的GUID不同
  if RegValueExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{710f4c1c-cc18-4c49-8cbf-51240c89a1a2}', 'Version') // Microsoft Visual C++ 2005 Redistributable X86 [XP/Win7 32位 V8.0.61001]
  or RegValueExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{ad8a2fa1-06e7-4b0d-927d-6e54b3d31028}', 'Version') // Microsoft Visual C++ 2005 Redistributable X64 [Win7 64位 V8.0.61000]
  or RegValueExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{071C9B48-7C32-4621-A0AC-3F809523288F}', 'Version') // Microsoft Visual C++ 2005 SP1 Redistributable X64 [Win7 64位 V8.0.56336]
    then
      begin
        vc8SP1Missing := false;
      end
    else
      begin
        vc8SP1Missing := true;
      end;
  result := true;
end;


[Run]
Filename: "{tmp}\vcredist_x86.exe"; Parameters: /q; WorkingDir: {tmp}; Flags: skipifdoesntexist; StatusMsg: "Install Microsoft Visual C++ 2005 Runtime ..."; Check: NeedInstallVC8SP1


你可能感兴趣的:(InnoSetup,运行时库)