I need to use a third-party DLL in our main application. When I statically refer to the provided DLL, it works fine, and I can export the DLLs. But we do not want our main application to depend on this DLL at startup, so I tried to dynamically load the DLL when I needed it:
DLLHandle := LoadLibrary('3rdparty.dll'); ret := GetLastError(); if DLLHandle = 0 then begin err := SysErrorMessage(ret); Writeln(err); end //...
but it doesnβt work: the LoadLibrary function returns 0, and LastErrorcode returns 3221225616. Since I donβt know what I am doing wrong, I tried the same (on the same PC) encoded in c and it works: but what does it not work with delphi ?: I call the same LoadLibrary function in the same DLL!
When I track using ProcMon, I see that 3rdparty dll is loading, and third-party dependency dlls and dlls are also loading. Thus, windows, of course, detect DLLs. But somewhere this loading process fails: When I try to load the DLL from LoadLibraryEX using DONT_RESOLVE_DLL_REFERENCES or LOAD_LIBRARY_AS_DATAFILE, it also works (but I cannot refuse to call the necessary functions ...)
I have no ideas: I hope you guys can help me ...
thanks in adv. Christoph
source share