innosetup脚本检测.net以及VC++

ruoyer 技术笔记评论2,100阅读模式

innosetup脚本检测.net以及VC++

一、检测.net以及VC++

[Files]
; VC Redistribute
Source: ".安装包vcredist2010x86.exe"; DestDir: "{tmp}"; Check: NeedInstallVC10
Source: ".安装包vcredist2013x86.exe"; DestDir: "{tmp}"; Check: NeedInstallVC13
; .net Framework
Source: ".安装包NDP452-x86-x64ENU.exe"; DestDir: "{tmp}"; Flags: ignoreversion {#IsExternal}; Check: NeedsFramework

[Run]
Filename: {tmp}NDP452-x86-x64ENU.exe; Parameters: "/q:a /c:""install /l /quiet"""; WorkingDir: {tmp}; Flags: skipifdoesntexist; StatusMsg: "Installing .NET Framework if needed"
Filename: {tmp}vcredist2010x86.exe; Parameters: "/q:a /c:""install /l /quiet"""; WorkingDir: {tmp}; Flags: skipifdoesntexist; StatusMsg: "Install Microsoft Visual C++ 2010 Runtime ...";
Filename: {tmp}vcredist2013x86.exe; Parameters: "/q:a /c:""install /l /quiet"""; WorkingDir: {tmp}; Flags: skipifdoesntexist; StatusMsg: "Install Microsoft Visual C++ 2013 Runtime ...";

[code]
//检测VC++
var
vc10SP1Missing: Boolean;
vc13SP1Missing: Boolean;
function NeedInstallVC10(): Boolean;
begin
Result :=  vc10SP1Missing;
end;

function NeedInstallVC13(): Boolean;
begin
Result :=  vc13SP1Missing;
end;

// 是否有.net4.0环境
function IsDotNET40Detected(): boolean;
var
success: boolean;
begin
success := RegKeyExists(HKLM, 'SOFTWAREMicrosoft.NETFrameworkPolicyv4.0');
Result :=  success;
end;
function NeedsFramework(): Boolean;
begin
Result := (IsDotNET40Detected = false );
end;

在函数 InitializeSetup()里给vc13SP1Missing与vc10SP1Missing赋值
//检测VC++2013
if RegValueExists(HKLM, 'SOFTWAREWOW6432NodeMicrosoftVisualStudio12.0VCRuntimesx86', 'Version') then
begin
vc13SP1Missing := false;
end
else
begin
vc13SP1Missing := true;
end;
//检测VC++2010
if RegValueExists(HKLM, 'SOFTWAREWOW6432NodeMicrosoftVisualStudio10.0VCVCRedistx86', 'Version') then
begin
vc10SP1Missing := false;
end
else
begin
vc10SP1Missing := true;
end;

ok完成。

 

 
ruoyer
  • 本文由 ruoyer 发表于 2021年12月1日20:26:01
  • 转载请务必保留本文链接:https://www.ruoyer.com/inno-vc.html

发表评论