在我的Inno安装代码中,我只在安装安装期间需要一些dll。
这些dll通过外部声明(使用{tmp}
关键字)在用户临时文件夹files:
中提取。
当安装程序终止时加载这些DLL文件。在安装结束时删除临时文件夹失败,日志文件包含以下错误消息:
Failed to remove temporary directory: C:\Users\<UserName>\AppData\Local\Temp\is-XXXX.tmp
所以我尝试在设置结束时用UnloadDll()
卸载并删除这些dll。 (来自DeinitializeSetup()
程序)
不幸的是,dll文件删除失败了,所以我认为UnloadDll()
调用并不是出于神秘的原因。我得到以下日志:
2018-03-23 10:42:50.583 Deinitializing Setup.
2018-03-23 10:42:50.584 Unable to delete C:\Users\<UserName>\AppData\Local\Temp\is-XXXX.tmp\SetupUtilities.dll
2018-03-23 10:42:52.619 Failed to remove temporary directory: C:\Users\<UserName>\AppData\Local\Temp\is-XXXX.tmp
2018-03-23 10:42:52.624 Log closed.
我做错了什么?
[Files]
Source: "Libraries\unzipper.dll"; Flags: dontcopy;
Source: "Utilities\bin\Release\SetupUtilities.dll"; Flags: dontcopy;
Source: "Components\DirectX_Redist_SciChart_19Feb15.zip"; DestDir: {tmp}; Flags: ignoreversion; AfterInstall: InstallDirectX
[code]
procedure unzip(src, target: AnsiString);
external 'unzip@files:unzipper.dll stdcall delayload';
function IsDirectX10Installed_(): boolean;
external 'IsDirectX10Installed@files:SetupUtilities.dll stdcall delayload';
function HasDirectX10CapableGpu_(): boolean;
external 'HasDirectX10CapableGpu@files:SetupUtilities.dll stdcall delayload';
function IsDirectXDependenciesInstalled_(): boolean;
external 'CheckDirectXDependencies@files:SetupUtilities.dll stdcall delayload';
function IsDirectXDependenciesInstalled(): Boolean;
begin
Result :=False;
Result:= IsDirectXDependenciesInstalled_();
end;
function HasDirectX10CapableGpu(): Boolean;
begin
Result :=False;
Result:= HasDirectX10CapableGpu_();
end;
procedure InstallDirectX();
var
ResultCodeDirectXInstallation: Integer;
begin
if not HasDirectX10CapableGpu then
begin
MsgBox('Your GPU is not compatible with the DirectX10 runtime.3D statistics will not be avalaible.', mbError, MB_OK);
end else
begin
if IsDirectXDependenciesInstalled then
begin
Log('DirectX is already installed');
end else
begin
unzip(ExpandConstant('{tmp}\DirectX_Redist_SciChart_19Feb15.zip'), ExpandConstant('{tmp}'));
ResultCodeDirectXInstallation := RunInstallation('Installing DirectX ...', '{tmp}\DXSETUP.exe', '/silent', False);
if not ResultCodeDirectXInstallation = 0 then
begin
MsgBox('An error occured during the DirectX installation.', mbError, MB_OK);
end;
end;
end;
end;
// Called when setup is terminated.
procedure DeinitializeSetup();
var UnzipperDllFileName, SetupUtilitiesDllFileName: string;
begin
UnzipperDllFileName := ExpandConstant('{tmp}\unzipper.dll')
SetupUtilitiesDllFileName := ExpandConstant('{tmp}\SetupUtilities.dll')
// Unload the DLLs
UnloadDLL(UnzipperDllFileName);
UnloadDLL(SetupUtilitiesDllFileName);
// Now we can delete the DLLs
if not DeleteFile(UnzipperDllFileName) then
begin
Log('Unable to delete ' + UnzipperDllFileName);
end;
if not DeleteFile(SetupUtilitiesDllFileName) then
begin
Log('Unable to delete ' + SetupUtilitiesDllFileName);
end;
end;