Inno setup 简单打包,安装脚本,检查NET Framework 环境,删除环境安装文件

; SEE THE DOCUMENTATION FOR DETAILS ON CREATING .ISS SCRIPT FILES!

#define MyAppName "我的软件名GCH"
#define MyAppVersion "1.0"
#define MyAppPublisher "软件作者GCH"
#define MyAppURL "作者网址GCH"
#define MyAppExeName "MyGCH测试.exe"

[Setup]
AppName=XX科技
AppVersion=2.5.0.0
DefaultDirName=E:\Dll\tt

OutputDir="E:\Dll"

[Types]
Name: "full"; Description: "Full installation"
Name: "compact"; Description: "Compact installation"
Name: "custom"; Description: "Custom installation"; Flags: iscustom

[Files]
Source: "E:\xx\bin\*"; DestDir: "{app}";Excludes: "*.pdb" ;Flags: ignoreversion recursesubdirs createallsubdirs


[code]
function Framework45IsNotInstalled(): Boolean;
var
  bSuccess: Boolean;
  regVersion: Cardinal;
begin
  Result := True;
  bSuccess := RegQueryDWordValue(HKLM,'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full','Release',regVersion);
  if (True = bSuccess) and (regVersion >= 378389) then begin
    Result := False;
  end;
end;

procedure InstallFramework;
var
  ResultCode: Integer;
  spath:string;
begin
  spath:='{app}\NDP461-KB3102436-x86-x64-AllOS-ENU.exe';
  if(FileOrDirExists(ExpandConstant(spath))) then 
    begin 
      Exec(ExpandConstant(spath), '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
    end;
end;

procedure CurStepChanged(CurStep: TSetupStep);
var   
 spath:string;
begin
  case CurStep of
    ssPostInstall:
      begin
          if Framework45IsNotInstalled() then
          begin
            InstallFramework();
          end;
        spath:='{app}\NDP461-KB3102436-x86-x64-AllOS-ENU.exe';
        DeleteFile(ExpandConstant(spath));
      end;
  end;
end;

Inno setup 安装脚本,检查NET Framework 环境,并删除安装文件

posted @ 2017-12-07 19:26  公寓城影子传说  阅读(406)  评论(0编辑  收藏  举报