问题
When I uninstall the program I get this error:
Cannot import dll: <utf8>c:\TestProg\IsStart.dll
What have I done wrong here? Can anybody help me to solve this problem?
CheckO4TaskMngrSvcStopAndUninstall
stops and deletes the O4TaskManager Service
:
Here's the code:
[Files]
Source: "IsStartServer.dll"; DestDir: "{tmp}"; DestName: IsStart.dll
Source: "IsStartServer.dll"; DestDir: "{app}"; DestName: IsStart.dll
Source: "sqlite3x86.dll"; DestDir: "{src}"; DestName: sqlite3.dll
Source: "sqlite3x86.dll"; DestDir: "{app}"; DestName: sqlite3.dll
Source: "sqlite3x64.dll"; DestDir: "{app}"
[Code]
function TaskMngrInst: LongBool;
external 'CheckO4TaskMngrSvcStopAndUninstall@files:IsStart.dll,sqlite3.dll stdcall loadwithalteredsearchpath setuponly';
function TaskMngrUninst: LongBool;
external 'CheckO4TaskMngrSvcStopAndUninstall@{app}\IsStart.dll stdcall uninstallonly';
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssInstall then
begin
TaskMngrInst();
end;
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usUninstall then
begin
TaskMngrUninst();
DeleteFile(ExpandConstant('{app}\sqlite3.dll'));
DeleteFile(ExpandConstant('{app}\IsStart.dll'));
RenameFile('{app}\sqlite3x64.dll)', '{app}\sqlite3.dll');
end;
end;
回答1:
I believe there was series of different problems (some of which were indeed based on my wrong suggestions).
The correct code is, imo:
[Files]
Source: "IsStartServer.dll"; DestDir: "{app}"; DestName: IsStart.dll
Source: "sqlite3x86.dll"; DestDir: "{app}"; DestName: sqlite3.dll
[Code]
function TaskMngrInst: LongBool;
external 'CheckO4TaskMngrSvcStopAndUninstall@files:IsStart.dll,sqlite3.dll stdcall loadwithalteredsearchpath setuponly';
function TaskMngrUninst: LongBool;
external 'CheckO4TaskMngrSvcStopAndUninstall@{app}\IsStart.dll stdcall loadwithalteredsearchpath uninstallonly';
The key points:
- Your original problem was the lack of loadwithalteredsearchpath flag in the import declaration for the uninstaller. You need it to load the dependencies (
sqlite3.dll
). - You need to install the dependencies (
sqlite3.dll
) to the{app}
for the use by the uninstaller. - The installed copy of the dependency has to match the name the primary DLL looks for (
sqlite3.dll
, notsqlite3x86.dll
). - The name of the DLLs in the
external
declaration has to match the destination filename (DestName: IsStart.dll
,DestName: sqlite3.dll
), not the original one. - The dependency must and can be listed in the declaration only when loading the DLLs from within the installer (with the
files:
prefix). Not when loading the DLL from a physical path ({app}\IsStart.dll
). The sole purpose for listing the dependency is for the installer to extract it (it does not load it, the primary DLL does, hence the the previous point). You do not need to list it, when loading physical files, as all files are (must be) installed already. If you use{app}\primary.dll,{app}\dependency.dll
, the uninstaller will actually try to load a file with a name{app}\primary.dll,{app}\dependency.dll
– obviously failing. - There's no point installing anything to
{tmp}
nor{src}
.
回答2:
IsStart.dll depends sqlite3.dll? May be it dont know what is sqlite3x86.dll. In totalcmd with some plugin, you can view missed dll
来源:https://stackoverflow.com/questions/65018560/loading-dll-with-dependencies-in-inno-setup-fails-in-uninstaller-with-cannot-im