如果在执行之前取消了对旧版本软件的取消安装

如果在执行之前取消了对旧版本软件的取消安装

本文介绍了如果在执行之前取消了对旧版本软件的取消安装,如何终止安装程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用innosetup创建了一个安装程序(myinstaller)来安装应用程序(myapp).代码段是:

I have created an installer(myinstaller) using innosetup to install an application (myapp).The code snippet is :

function legacy_check(): Boolean;
    begin
       ShellExec('runas', 'rundll32.exe', 'dfshim.dll,ShArpMaintain SecretsUtility.application, Culture=neutral, PublicKeyToken=0000000000000000, processorArchitecture=amd64', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
       Result := True;
    end;

function InitializeSetup(): Boolean;
    begin
       Result:=legacy_check(); // after this line only inno setup wizard page will appear
       // code to install latest version
     end;

在这里,函数legacy_check()检查系统中是否存在旧版本的 myapp ,并将其卸载并返回true.以便 myinstaller 可以继续进行.

Here the function legacy_check() checks for existance of old version of myapp in the system and uninstalls it and returns true . so that myinstaller can proceed further .

但是,在此期间,在卸载旧版本时,它会询问用户是否要卸载.那时,如果用户按OK进行卸载,则可以正常工作.但是,如果用户按Cancel来卸载旧版本,则应终止 myinstaller .但它不会终止,因为无论如何它都会返回True.

But, here during uninstallation of old version , it asks user whether to uninstall or not. That time if user presses OK to uninstall, it works fine .But if user presses cancel to uninstall old version ,it should terminate myinstaller.But it is not terminating Since it returns True anyway.

因此,我认为当用户按下取消"按钮进行卸载时,我需要获取一些返回码,以便使用返回码可以返回true或false.

So i think i need to get some return code when user presses cancel button to uninstall ,so that using return code i can return either true or false .

所以当用户按下cancel卸载时,有什么方法可以获取返回码,以便我可以在行后使用它,

So Is there any way to get returncode when user presses cancel to uninstall , so that i can use it after the line,

ShellExec('runas', 'rundll32.exe', 'dfshim.dll,ShArpMaintain SecretsUtility.application, Culture=neutral, PublicKeyToken=0000000000000000, processorArchitecture=amd64', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);  ?

否则,请告诉我如何以静默方式将其卸载.我对如何在 ShellExec 中使用/SILENT 参数感到困惑,因为已经存在参数.所以请给我建议一下.

otherwise please tell me how to uninstall it silently . I am confused about how to use /SILENT parameter in ShellExec since there are parameters present already .So please suggest me some idea.

推荐答案

我如下更改代码以实现要求:

I changed my code as below to achieve the requirement :

function legacy_check(): Boolean;
begin
   ShellExec('runas', 'rundll32.exe', 'dfshim.dll,ShArpMaintain SecretsUtility.application, Culture=neutral, PublicKeyToken=0000000000000000, processorArchitecture=amd64', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
   if RegKeyExists(HKEY_CURRENT_USER,'Software\Microsoft\Windows\CurrentVersion\Uninstall\myapp') then
                  Result := False
               else
                  Result := True;
end;

function InitializeSetup(): Boolean;
begin
   Result:=legacy_check();
    if Not Result then
    begin
       Result:=False
    else
      // code to install latest version
end;

这篇关于如果在执行之前取消了对旧版本软件的取消安装,如何终止安装程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 19:00