1
我正在使用Inno安装脚本并在卸载过程中调用自定义DLL来执行一些还原操作。不幸的是,卸载完成后,DLL和它的依赖不会被删除,尽管我调用了UnloadDLL和DeleteFile。 为什么UnloadDLL失败? 有没有可能使用LoadLibrary加载动态链接库?我已经看到了一些这方面的功能,但它们都被弃用了。Inno安装程序:UnloadDLL在卸载时不起作用
下面的代码:
function Revert(param: String): cardinal;
external '[email protected]{app}\Revert.dll cdecl delayload uninstallonly';
procedure RevertAll();
var
param: String;
dataDirectory: String;
temp: String;
i: Integer;
begin
dataDirectory := ExpandConstant('{commonappdata}\MyAppData');
StringChangeEx(dataDirectory, '\', '\\', True);
param := '{"dataDirectory": "' + dataDirectory + '", "registryPath" : "SOFTWARE\\MyReg\\Key"}';
Revert(param);
temp := ExpandConstant('{app}\Revert.dll');
for i := 0 to 10 do
begin
UnloadDLL(temp);
Sleep(500);
if DeleteFile(temp) then
break;
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if (CurUninstallStep = usUninstall) then
begin
RevertAll();
end
end;
是什么'DeleteFile'返回? –
它返回false。 – dJonzo
请注意:'StringChangeEx(dataDirectory,'\','\\',True);'有点危险。如果“\\”已经存在于'dataDirectory'中,结果将是“\\\\”! –