From d8ab54234b51751a63fe55d0d6ec751eac12d743 Mon Sep 17 00:00:00 2001 From: yangjiaxuan <171295266@qq.com> Date: Mon, 8 Jan 2024 09:54:12 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E5=B7=A5=E5=85=B7=E6=89=93?= =?UTF-8?q?=E5=8C=85=E8=84=9A=E6=9C=AC=EF=BC=8C=E8=A6=86=E7=9B=96=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E6=9B=B4=E6=94=B9=E4=B8=BA=E5=8D=B8=E8=BD=BD=E5=AE=89?= =?UTF-8?q?=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HGProductionTool_App_Setup.iss | 117 +++++++++++++++++- 1 file changed, 114 insertions(+), 3 deletions(-) diff --git a/win/setup/productiontool/HGProductionTool_App_Setup.iss b/win/setup/productiontool/HGProductionTool_App_Setup.iss index 8c980f9..3b59ab2 100644 --- a/win/setup/productiontool/HGProductionTool_App_Setup.iss +++ b/win/setup/productiontool/HGProductionTool_App_Setup.iss @@ -30,7 +30,15 @@ PrivilegesRequired=admin DisableWelcomePage=no [Languages] -Name: "zn"; MessagesFile: "compiler:Languages/ChineseSimp.isl" +Name: "chinese_simp"; MessagesFile: "compiler:Languages/ChineseSimp.isl"; LicenseFile:HGProductionTool_App_License.txt + +[CustomMessages] +chinese_simp.MyAppName=华高生产工具 +chinese_simp.MyAppPublisher=宁波华高信息科技有限公司 +chinese_simp.MyStr1=软件已安装,是否卸载原版本? +chinese_simp.MyStr2=请先关闭旧版软件! +chinese_simp.MyStr3=卸载旧版软件失败,停止安装! +chinese_simp.MyStr4=请先关闭软件! [Files] @@ -64,17 +72,102 @@ Source: "..\..\usb\huagao\hgscannerusball.cat"; DestDir: "{app}\driver\"; Flags Source: "..\..\x86\Release\DPInst32.exe"; DestDir: "{app}\"; Flags: ignoreversion recursesubdirs; Check: not IsWin64 Source: "..\..\x64\Release\DPInst64.exe"; DestDir: "{app}\"; Flags: ignoreversion recursesubdirs; Check: IsWin64 +; 临时使用 +Source: "..\..\x86\Release\RemoveOldApp.exe"; DestDir: "{tmp}\"; Flags: ignoreversion +Source: "..\..\x86\Release\CheckNewApp.exe"; DestDir: "{app}\"; Flags: ignoreversion; Check: not Is64BitInstallMode +Source: "..\..\x64\Release\CheckNewApp.exe"; DestDir: "{app}\"; Flags: ignoreversion; Check: Is64BitInstallMode [INI] [Icons] Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\ProductionTool.exe" Name: "{group}\{#MyAppName}"; Filename: "{app}\ProductionTool.exe" -Name: "{group}\{cm:UninstallProgram, {#MyAppName}}"; Filename: "{uninstallexe}"; +Name: "{group}\卸载 {cm:UninstallProgram, {#MyAppName}}"; Filename: "{uninstallexe}"; + +[Registry] +Root: HKLM; Subkey: "Software\ProductionTool"; ValueType: string; ValueName: "AppDirectory"; ValueData: "{app}"; Flags: uninsdeletekey +Root: HKLM; Subkey: "Software\ProductionTool"; ValueType: string; ValueName: "Application"; ValueData: "{app}\ProductionTool.exe"; Flags: uninsdeletekey +Root: HKLM; Subkey: "Software\ProductionTool"; ValueType: string; ValueName: "AppVersion"; ValueData: "{#MyAppVersion}"; Flags: uninsdeletekey +Root: HKLM; Subkey: "Software\ProductionTool"; ValueType: string; ValueName: "DriverPath"; ValueData: "{app}"; Flags: uninsdeletekey; Check: not Is64BitInstallMode [Code] -function SetUninstallIcon(iconPath:string): Boolean; + + var + globalInstallPath: String; + +procedure InitializeWizard; +begin + WizardForm.DirEdit.Text := globalInstallPath; +end; + +function GetInstallString(): String; +var + InstallPath: String; +begin + InstallPath := ExpandConstant('{pf}\{#MyAppDefSetupDir}'); + if RegValueExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{52021EA6-BCE5-4E07-8766-B6DC7C61FB51}_is1', 'Inno Setup: App Path') then + begin + RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{52021EA6-BCE5-4E07-8766-B6DC7C61FB51}_is1', 'Inno Setup: App Path', InstallPath) + end + result := InstallPath; +end; + +function InitializeSetup(): boolean; +var + ErrorCode: Integer; + ResultCode: Integer; + ResultStr: String; + UninstallContinue: Boolean; + CmdStr: String; +begin + Result := false; + globalInstallPath := GetInstallString(); + CmdStr := GetCmdTail(); + ExtractTemporaryFile('RemoveOldApp.exe'); + if Exec(ExpandConstant('{tmp}\RemoveOldApp.exe'), '', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode) then + begin + if 0 = ErrorCode then + begin + if RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{52021EA6-BCE5-4E07-8766-B6DC7C61FB51}_is1', 'UninstallString', ResultStr) then + begin + UninstallContinue := true; + if Pos('/verysilent', CmdStr) = 0 then + begin + if MsgBox(ExpandConstant('{cm:MyStr1}'), mbConfirmation, MB_YESNO) <> IDYES then + begin + UninstallContinue := false; + end + end + if UninstallContinue then + begin + ResultStr := RemoveQuotes(ResultStr); + if Exec(ResultStr, '/verysilent', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then + begin + if 0 = ResultCode then + begin + Sleep(1000) + Result := true; + end + end + end + end + else + begin + Result := true; + end + end + else if 2 = ErrorCode then + begin + MsgBox(ExpandConstant('{cm:MyStr2}'), mbInformation, MB_OK); + end + else + begin + MsgBox(ExpandConstant('{cm:MyStr3}'), mbInformation, MB_OK); + end + end +end; + function SetUninstallIcon(iconPath:string): Boolean; var InstalledVersion,SubKeyName: String; begin @@ -82,6 +175,24 @@ begin RegWriteStringValue(HKLM,SubKeyName,'DisplayIcon',iconPath); end; +function InitializeUninstall(): Boolean; +var + ErrorCode: Integer; +begin + Result := false; + if Exec(ExpandConstant('{app}\CheckNewApp.exe'), '', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode) then + begin + if 0 = ErrorCode then + begin + Result := true; + end + else + begin + MsgBox(ExpandConstant('{cm:MyStr4}'), mbInformation, MB_OK); + end + end +end; + procedure CurPageChanged(CurPageID: Integer); begin if CurPageID = wpFinished then