; Inno Setup Script for 包装商城发货助手 ; Requires Inno Setup 6.x #define MyAppName "包装商城发货助手" #define MyAppVersion "1.0.1" #define MyAppPublisher "PackagingMall" #define MyAppExeName "PackagingMallShipper.exe" [Setup] AppId={{A1B2C3D4-E5F6-7890-ABCD-EF1234567890} AppName={#MyAppName} AppVersion={#MyAppVersion} AppPublisher={#MyAppPublisher} DefaultDirName={autopf}\{#MyAppName} DefaultGroupName={#MyAppName} AllowNoIcons=yes OutputDir=installer OutputBaseFilename=PackagingMallShipper_Setup_v{#MyAppVersion} Compression=lzma2/ultra64 SolidCompression=yes PrivilegesRequired=admin MinVersion=6.1 ArchitecturesAllowed=x86compatible x64compatible WizardStyle=classic DisableProgramGroupPage=yes UninstallDisplayName={#MyAppName} UninstallDisplayIcon={app}\{#MyAppExeName} [Languages] Name: "chinesesimplified"; MessagesFile: "compiler:Languages\ChineseSimplified.isl" [Tasks] Name: "desktopicon"; Description: "创建桌面快捷方式"; GroupDescription: "附加选项:"; Flags: checkedonce [Files] Source: "publish\PackagingMallShipper.exe"; DestDir: "{app}"; Flags: ignoreversion Source: "publish\PackagingMallShipper.exe.config"; DestDir: "{app}"; Flags: ignoreversion Source: "publish\x64\SQLite.Interop.dll"; DestDir: "{app}\x64"; Flags: ignoreversion Source: "publish\x86\SQLite.Interop.dll"; DestDir: "{app}\x86"; Flags: ignoreversion [Icons] Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" Name: "{group}\卸载 {#MyAppName}"; Filename: "{uninstallexe}" Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon [Run] Filename: "{app}\{#MyAppExeName}"; Description: "运行 {#MyAppName}"; Flags: nowait postinstall skipifsilent [Code] function IsDotNetInstalled: Boolean; var Release: Cardinal; begin Result := False; if RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full', 'Release', Release) then begin Result := (Release >= 394802); end; end; function GetDotNetVersionStr: String; var Release: Cardinal; begin Result := '未安装'; if RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full', 'Release', Release) then begin if Release >= 533320 then Result := '4.8.1 或更高' else if Release >= 528040 then Result := '4.8' else if Release >= 461808 then Result := '4.7.2' else if Release >= 461308 then Result := '4.7.1' else if Release >= 460798 then Result := '4.7' else if Release >= 394802 then Result := '4.6.2' else if Release >= 394254 then Result := '4.6.1' else if Release >= 393295 then Result := '4.6' else Result := '4.5.x 或更低'; end; end; function InitializeSetup: Boolean; var ErrorCode: Integer; NetVersion: String; begin Result := True; if not IsDotNetInstalled then begin NetVersion := GetDotNetVersionStr; if MsgBox('此程序需要 .NET Framework 4.6.2 才能运行。' + #13#10 + #13#10 + '当前检测到的版本: ' + NetVersion + #13#10 + #13#10 + '是否要打开微软官网下载 .NET Framework 4.6.2?' + #13#10 + '(下载完成后请先安装运行时,再重新运行此安装程序)', mbConfirmation, MB_YESNO) = IDYES then begin ShellExec('open', 'https://dotnet.microsoft.com/download/dotnet-framework/net462', '', '', SW_SHOW, ewNoWait, ErrorCode); end; Result := MsgBox('是否仍要继续安装?' + #13#10 + #13#10 + '注意:如果没有安装 .NET Framework 4.6.2,程序将无法运行。', mbConfirmation, MB_YESNO) = IDYES; end; end; procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); var DataDir: String; begin if CurUninstallStep = usPostUninstall then begin DataDir := ExpandConstant('{localappdata}\PackagingMallShipper'); if DirExists(DataDir) then begin if MsgBox('是否删除程序数据(包括本地缓存的订单数据)?', mbConfirmation, MB_YESNO) = IDYES then begin DelTree(DataDir, True, True, True); end; end; end; end;