; -- Example1.iss -- ; Demonstrates copying 3 files and creating an icon. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING .ISS SCRIPT FILES! [Setup] AppName=RouteEMT AppVersion=v1.0.0 WizardStyle=modern DefaultDirName={autopf}\RouteEMTV1.0.0 DefaultGroupName=RouteEMTV1.0.0 UninstallDisplayIcon={app}\uninstall_RouteEMTV1.0.0.exe Compression=lzma2 SolidCompression=yes OutputDir=userdocs:Inno Setup Examples Output ShowLanguageDialog = yes [Languages] Name: "chinese"; MessagesFile: "compiler:Languages\Chinese.isl" [Files] Source: "RouteEmt.exe"; DestDir: "{app}" Source: "路由器返修配置.xml"; DestDir: "{app}" Source: "WinPcap_4_1_1.exe"; DestDir: "{app}" [Run] Filename: "{app}\WinPcap_4_1_1.exe"; Check: ShouldInstall [Code] function ShouldInstall: Boolean; var Version: String; install: cardinal; begin // 检查软件版本是否已安装 if RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full', 'Install', install) then begin // 已经安装了最新版本,不需要再次安装 MsgBox(Format('install is %d.', [install]), mbInformation, MB_OK); Result := (install =1); Exit; end; Result := True; end; procedure AfterMyProgInstall(S: String); var FileName: String; ResultCode: Integer; begin Log('AfterMyProgInstall(''' + S + ''') called'); //MsgBox('AfterMyProgInstall:' #13#13 'Setup just installed ' + S + ' as ' + CurrentFileName + '.', mbInformation, MB_OK); //MsgBox('安装程序将要安装: ' + S + ',如果已经安装,程序会给出提示', mbInformation, MB_OK); FileName := ExpandConstant('{app}')+'\'+S; if not Exec(FileName, '', '', SW_SHOWNORMAL, ewNoWait, ResultCode) then MsgBox('依赖安装失败:' +S,mbInformation,MB_OK); end; function IsDotNetDetected(version: string; service: cardinal): boolean; var key, versionKey: string; install, release, serviceCount, versionRelease: cardinal; success: boolean; begin versionKey := version; versionRelease := 0; // .NET 1.1 and 2.0 embed release number in version key if version = 'v1.1' then begin versionKey := 'v1.1.4322'; end else if version = 'v2.0' then begin versionKey := 'v2.0.50727'; end // .NET 4.5 and newer install as update to .NET 4.0 Full else if Pos('v4.', version) = 1 then begin versionKey := 'v4\Full'; case version of 'v4.5': versionRelease := 378389; 'v4.5.1': versionRelease := 378675; // 378758 on Windows 8 and older 'v4.5.2': versionRelease := 379893; 'v4.6': versionRelease := 393295; // 393297 on Windows 8.1 and older 'v4.6.1': versionRelease := 394254; // 394271 on Windows 8.1 and older 'v4.6.2': versionRelease := 394802; // 394806 on Windows 8.1 and older end; end; // installation key group for all .NET versions key := 'SOFTWARE\Microsoft\NET Framework Setup\NDP\' + versionKey; // .NET 3.0 uses value InstallSuccess in subkey Setup if Pos('v3.0', version) = 1 then begin success := RegQueryDWordValue(HKLM, key + '\Setup', 'InstallSuccess', install); end else begin success := RegQueryDWordValue(HKLM, key, 'Install', install); end; // .NET 4.0 and newer use value Servicing instead of SP if Pos('v4', version) = 1 then begin success := success and RegQueryDWordValue(HKLM, key, 'Servicing', serviceCount); end else begin success := success and RegQueryDWordValue(HKLM, key, 'SP', serviceCount); end; // .NET 4.5 and newer use additional value Release if versionRelease > 0 then begin success := success and RegQueryDWordValue(HKLM, key, 'Release', release); success := success and (release >= versionRelease); end; result := success and (install = 1) and (serviceCount >= service); end; function InitializeSetup(): Boolean; var Path:string; ResultCode: Integer; begin if not IsDotNetDetected('v4.5', 0) then begin ExtractTemporaryFile('NDP452-KB2901907-x86-x64-AllOS-ENU.exe'); Exec(ExpandConstant('{tmp}\NDP452-KB2901907-x86-x64-AllOS-ENU.exe'), '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode); result := true; end else result := true; end; [Icons] Name: "{group}\RouteEMTV1.0.0"; Filename: "{app}\RouteEmt.exe"
标签:begin,end,success,setup,version,6.2,install,inno,versionRelease From: https://www.cnblogs.com/cnchengv/p/17787965.html