2017-02-09 306 views
2

我已经安装了我的程序。但是如果我尝试再次安装它,它会执行并且程序被替换。Inno Setup - 如何防止安装应用程序时的安装?

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

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

回答

3

您不需要创建任何注册表项。安装程序已经为卸载程序创建了一个注册表项。你可以检查一下。这是相同的关键,​​你提到的问题的答案使用。但是你不需要检查版本。只要检查存在。你也应该同时检查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; 

The application is installed already

相关问题