【问题标题】:Inno Setup - How to prevent installation when application is installed already?Inno Setup - 如何在已安装应用程序时阻止安装?
【发布时间】:2017-06-27 10:30:46
【问题描述】:

我已经安装了我的程序。但是如果我再次尝试安装它,它会安装并且程序会被替换。

我看到了这个问题Inno Setup - How to display notifying message while installing if application is already installed on the machine?

我可以创建一个特定的注册表项,以便我可以检查它并阻止新安装吗?在这个问题中有一些相关信息:Skip installation in Inno Setup if other program is not installed

【问题讨论】:

    标签: inno-setup


    【解决方案1】:

    您不需要创建任何注册表项。安装程序已经为卸载程序创建了一个注册表项。你可以检查一下。您所指的问题的答案使用的是同一把钥匙。但是您不需要检查版本。只需检查存在。您还应该检查HKEY_LOCAL_MACHINEHKEY_CURRENT_USER

    #define AppId "myapp"
    
    [Setup]
    AppId={#AppId}
    
    [Code]
    
    function InitializeSetup(): Boolean;
    begin
      Result := True;
      if RegKeyExists(HKEY_LOCAL_MACHINE,
           'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#AppId}_is1') or
         RegKeyExists(HKEY_CURRENT_USER,
           'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#AppId}_is1') then
      begin
        MsgBox('The application is installed already.', mbInformation, MB_OK);
        Result := False;
      end;
    end;
    


    或者只是重用来自Can Inno Setup respond differently to a new install and an update?IsUpgrade函数

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-29
      • 1970-01-01
      相关资源
      最近更新 更多