我之前在Inno Setup中的安装(A)具有AppID = {{8ADA0E54-F327-4717-85A9-9DE3F8A6D100}。

我有另一个具有不同AppID的安装(B),我想将其安装到与安装(A)相同的目录中。

如何自动获取DefaultDirName?我不想使用相同的AppID,因为当我卸载安装(B)并且安装(A)保持安装状态时,它将从注册表中删除AppID字符串(安装(A)字符串)。

你能帮我吗?

最佳答案

您可能需要一些代码才能执行所需的操作。您还需要一种方法来查找应用程序A的安装目录。这是我使用的一些代码

[Setup]
DefaultDirName={code:GetDefaultDir}

[Code]
function GetDefaultDir(def: string): string;
var
sTemp : string;
begin
    //Set a defualt value so that the install doesn't fail.
    sTemp := ExpandConstant('{pf}') + '\MyCompany\MyAppA';

    //We need to get the current install directory.
    if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'Software\MyCompany\Products\MyAppNameA',
     'InstallDir', sTemp) then
     begin
    //We found the value in the registry so we'll use that.  Otherwise we use the default
     end;
    Result := sTemp;
end;

10-07 19:10
查看更多