Inno SetupインストールVS 2005実行環境の確認


Inno Setupは、プログラムのインストール時に、登録フォームを確認してVS 2005の実行環境がインストールされているかどうかを判断し、インストールされていない場合はインストールすることができます.
#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