I'm not so sure LOAD_WITH_ALTERED_SEARCH_PATH is a good solution, at least not the way libraries are loaded at the moment.
According to
MSDN:
If this value is used and lpFileName specifies an absolute path, the system uses the alternate file search strategy discussed in the Remarks section to find associated executable modules that the specified module causes to be loaded. If this value is used and lpFileName specifies a relative path, the behavior is undefined.
If this value is not used, or if lpFileName does not specify a path, the system uses the standard search strategy discussed in the Remarks section to find associated executable modules that the specified module causes to be loaded.
This value cannot be combined with any LOAD_LIBRARY_SEARCH flag.
The benefit of changing the directory and calling the basic functions are:
- Should work fine on Unix and WIndows
- Should work fine on FPC and older versions of Delphi too (I don't know when LoadLibraryEx was added to Windows.pas, so we do not overdefine)
- Should work with relative paths as well
I doubt it's because of different VC runtime, they should be in the search path and client DLLs should find them automatically. If you ask me it's an Oracle specialty. Try with 19.8.0; this issue disappeared for me when I upgraded both Oracle and the FreeTDS driver to the latest (also, Zeos to 8.0.0-9a2564ea from GIT). Oracle as the common point fills me with confidence, however if the update does not solve your problem we should investigate further on different platforms too (Linux, FPC) if they are affected.
MJFShark wrote: ↑26.10.2020, 13:43Alternately, is there a way to free a driver dll programmatically? It looks like FreeLibrary is never called until program exit (or at least I couldn't find a way to cause it.)
Even if you could, don't do it. If LoadLibrary really can not find the correct module, this issue has to be fixed on Zeos level: forcing it to unload is a really "hacky" workaround. Plus it can cause other connections to reset.
On the other hand keeping the libraries opened until the end of times is NOT a good solution, I don't like this in Zeos either. It's really annoying if I want to update the client libs and I have to close my program to be able to do so. I'd expect it to be released when the (last) connection is disconnected which is using this library.