华高打包脚本,安装前先进行卸载

This commit is contained in:
luoliangyi 2022-11-24 20:51:13 +08:00
parent f7573252be
commit aa55a96d1c
1 changed files with 41 additions and 4 deletions

View File

@ -1,7 +1,7 @@
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "华高扫描软件"
#define MyAppVersion "4.36.10100.22327"
#define MyAppVersion "4.36.10100.22328"
#define MyAppSetupName "HuaGoScan_App_Setup"
#define MyAppDefSetupDir "HuaGoScan"
#define MyAppPublisher "宁波华高信息科技有限公司"
@ -196,21 +196,58 @@ Root: HKLM; Subkey: "Software\WOW6432Node\HuaGoScan"; ValueType: string; ValueNa
Root: HKLM; Subkey: "Software\WOW6432Node\HuaGoScan"; ValueType: string; ValueName: "DriverPath64"; ValueData: "{app}"; Flags: uninsdeletekey; Check: Is64BitInstallMode
[Code]
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\{7076DC53-5C2F-4216-9783-2A6F954FEB3E}_is1', 'Inno Setup: App Path') then
begin
RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{7076DC53-5C2F-4216-9783-2A6F954FEB3E}_is1', 'Inno Setup: App Path', InstallPath)
end
result := InstallPath; end;
function InitializeSetup(): boolean;
var
ErrorCode: Integer;
ResultCode: Integer;
ResultStr: String;
begin
Result := false;
globalInstallPath := GetInstallString();
ExtractTemporaryFile('HGRemoveOldApp.exe');
if Exec(ExpandConstant('{tmp}\HGRemoveOldApp.exe'), '', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode) then
begin
if 0 = ErrorCode then
begin
Result := true;
if RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{7076DC53-5C2F-4216-9783-2A6F954FEB3E}_is1', 'UninstallString', ResultStr) then
begin
ResultStr := RemoveQuotes(ResultStr);
if Exec(ResultStr, '/silent', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then
begin
if 0 = ResultCode then
begin
Result := true;
end
end
end
else
begin
Result := true;
end
end
else if 2 = ErrorCode then
begin
MsgBox('请关闭旧版扫描软件再卸载!', mbInformation, MB_OK);
MsgBox('请关闭旧版扫描软件!', mbInformation, MB_OK);
end
else
begin
@ -241,7 +278,7 @@ begin
end
else
begin
MsgBox('请关闭扫描软件再卸载', mbInformation, MB_OK);
MsgBox('请关闭扫描软件!', mbInformation, MB_OK);
end
end
end;