Inno Setup打包之先卸载再安装

使用Inno Setup打包程序之后,如果想要在安装前先卸载,那么需要加下面代码,需要注意的是红色标注的改为你们自己的。网上看到有些说_is1前面用AppName,但是我这边验证不行。

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{AE806707-B582-44AE-A42A-12A5DEE6173E}

[Code]  
function InitializeSetup(): boolean;  
var  
  ResultStr: String;  
  ResultCode: Integer;  
begin  
  if RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{AE806707-B582-44AE-A42A-12A5DEE6173E}_is1', 'UninstallString', ResultStr) then  
    begin  
      ResultStr := RemoveQuotes(ResultStr);  
      Exec(ResultStr, '/silent', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);  
    end;  
    result := true;  
end;

 

posted on 2019-03-12 13:54  liujx2019  阅读(911)  评论(0编辑  收藏  举报

导航