天天看點

inno setup靜默安裝vcredist_x86.exe,并判斷是否已經安裝過

;靜默安裝vcredist_x86.exe
[Run]
Filename: {app}\vcredist_x86.exe; Parameters: /q; WorkingDir: {tmp}; Flags: skipifdoesntexist; StatusMsg: "Installing Microsoft Visual C++ Runtime ..."; Check: NeedInstallVC9SP1

[Code]
var
 vc9SP1Missing: Boolean;

function NeedInstallVC9SP1(): Boolean;
begin
 Result := vc9SP1Missing;
end;

function InitializeSetup(): Boolean;
var
 version: Cardinal;
begin
 if RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{9A25302D-30C0-39D9-BD6F-21E6EC160475}', 'Version', version) = false
 then
   begin
     vc9SP1Missing := true;
   end;
 result := true;
end;           

注意:如果要判斷是否已經安裝過vs運作時庫,需要去系統資料庫讀出安裝的UUID