在应用程序B我有以下代码在[Run]
部分:
Filename: "{dotnet40}regasm.exe";
Parameters: "/u PTSTools_x86.dll";
WorkingDir: "{app}";
Flags: runhidden;
Check: FileExists(ExpandConstant('{app}PTSTools_x86.dll'));
AfterInstall: DoDeleteFile(ExpandConstant('{app}PTSTools_x86.dll'))
Filename: "{dotnet4064}regasm.exe";
Parameters: "/u PTSTools_x64.dll";
WorkingDir: "{app}";
Flags: runhidden;
Check: IsWin64 and FileExists(ExpandConstant('{app}PTSTools_x64.dll'));
AfterInstall: DoDeleteFile(ExpandConstant('{app}PTSTools_x64.dll'))
我曾经在应用程序B中使用那些DLL文件,但不再需要了。所以我执行了上面的"未注册"one_answers"摆脱"它们。这本身是没问题的。但是…我有一个应用程序A确实使用了它们!因此,在[Run]
部分中确实有:
Filename: "{dotnet40}regasm.exe";
Parameters: "PTSTools_x86.dll /codebase";
WorkingDir: "{app}";
Flags: runhidden
Filename: "{dotnet4064}regasm.exe";
Parameters: "PTSTools_x64.dll /codebase";
WorkingDir: "{app}";
Flags: runhidden;
Check: IsWin64
现在,两个应用程序是相互独立的。用户可以有一个,也可以有另一个,或者两者都有。
- 如果他们只有应用程序B那么它可以注销和删除过时的DLL文件。
- 如果他们也安装了应用程序A,那么,过时的DLL文件只需要删除,因为应用程序A会在其文件夹中注册它们。
我可以执行此选择卸载行为吗?
检查应用程序A是否未安装后,使用Exec
函数从CurStepChanged(ssInstall)
调用regasm /u
检查是否安装了应用程序A,使用与这里相同的代码:
Inno Setup对新安装和更新的响应是否不同?
如果在Inno Setup中更新了安装,则排除ssPostInstall步骤中的Code部分
只需使用应用程序A的AppId
。
procedure Unregister(Filename: string);
var
Path, FilePath: string;
ResultCode: Integer;
begin
Path := ExpandConstant('{app}');
FilePath := AddBackslash(Path) + Filename;
if not FileExists(FilePath) then
begin
Log(Format('%s does not exist', [FilePath]));
end
else
begin
if IsAppAInstalled then
begin
Log(Format('Application A is installed, not unregistering %s', [FilePath]));
end
else
begin
if Exec(ExpandConstant('{dotnet40}regasm.exe'), '/u ' + Filename,
Path, SW_HIDE, ewWaitUntilTerminated,
ResultCode) and
// Not sure about this
(ResultCode = 0) then
begin
Log(Format('Unregistered %s', [FilePath]));
end
else
begin
Log(Format('Failed to unregister %s', [FilePath]));
end;
end;
if DeleteFile(FilePath) then
begin
Log(Format('Deleted %s', [FilePath]));
end
else
begin
Log(Format('Failed to delete %s', [FilePath]));
end;
end;
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssInstall then
begin
Unregister('PTSTools_x86.dll');
if IsWin64 then Unregister('PTSTools_x64.dll');
end;
end;
这是基于接受的答案,并进行了一些小调整:
- 调整1
在CurStepChanged
中,我将其更改为取消注册64位DLL的条件:
else if (CurStep = ssInstall) then
begin
Unregister('PTSTools_x86.dll', ExpandConstant('{dotnet40}'));
if (IsWin64) then
begin
Unregister('PTSTools_x64.dll', ExpandConstant('{dotnet4064}'));
end;
end
- 调整2
我修改了Unregister
以接受第二个参数(扩展后的{dotnet40}
常量的值)。然后用它来构建到regasm
的路径:
RegAsmPath := AddBackSlash(sDotNetRoot) + 'regasm.exe';
然后我简单地使用该值作为Exec
的第一个参数。