innosetup进阶使用以及官方文档

一、检测.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, 'SOFTWARE\Microsoft\.NETFramework\Policy\v4.0');
    Result :=  success;
end;
function NeedsFramework(): Boolean;
begin
  Result := (IsDotNET40Detected = false );
end;

在函数 InitializeSetup()里给vc13SP1Missing与vc10SP1Missing赋值
   //检测VC++2013
   if RegValueExists(HKLM, 'SOFTWARE\WOW6432Node\Microsoft\VisualStudio\12.0\VC\Runtimes\x86', 'Version') then
      begin
        vc13SP1Missing := false;
      end
    else
      begin
       vc13SP1Missing := true;
      end;
//检测VC++2010
  if RegValueExists(HKLM, 'SOFTWARE\WOW6432Node\Microsoft\VisualStudio\10.0\VC\VCRedist\x86', 'Version') then
      begin
        vc10SP1Missing := false;
      end
    else
      begin
        vc10SP1Missing := true;
      end;

ok完成。

二、MsgBox的三按钮选择

case MsgBox('安装程序检测到 {#MyAppName} 已安装!'#13''#13'单击“是”按钮保留数据继续安装;'#13''#13'单击“否”按钮卸载;'#13''#13'单击“取消”按钮退出安装!', mbConfirmation, MB_YESNOCANCEL) of
 IDYES:
    begin 
        Result:= true;
    end;
 IDNO:
    begin
       AppExisPathUn := RemoveQuotes(AppExisPathUn); 
       Exec(AppExisPathUn, '', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);   
       Result:= false; 
    end;
 IDCANCEL:
    begin
      Result:= false;
    end; 
end;

三,文档 点击进入

推荐阅读更多精彩内容