Re: LibraryLoader loads wrong DLL
Thor Andreas Tangen <[email protected]> Wed, 14 Mar 2012 12:13:42 +0100
| Newsgroups | gmane.comp.python.ctypes |
|---|---|
| Message-ID | <CA+wbTUrOQ8b-Fc3P0RvwHO9iAWf57cC387uDVEqsk1W0RcNo3A@mail.gmail.com> |
Hi, I found a solution to the problem. I use SetDllDirectory (http://msdn.microsoft.com/en-us/library/windows/desktop/ms686203(v=vs.85).aspx) with the path to my interface.dll before trying to load it or run ctypesgen. After loading I set it back to default using SetDllDirectory(NULL). Thor Andreas On Wed, Mar 14, 2012 at 10:26 AM, Thor Andreas Tangen <[email protected]> wrote: > Hi, > > Thanks for the link. I have tried using my interface in a C-program, > and there the loading is correct, so why is the loading different > there from what is done in ctypes? How are the search directories set > in ctypes? > > I'll try the trick you propose and see if its a workaround > > Thanks, > Thor Andreas > > On Wed, Mar 14, 2012 at 10:07 AM, Thomas Heller <[email protected]> wrote: >> Am 14.03.2012 09:31, schrieb Thor Andreas Tangen: >>> Hi >>> >>> I have a DLL, lets call it interface.dll, which wraps a C++ API. This >>> C++ API depends on another API located in console.dll. This >>> console.dll is shipped with the C++ API and is specific to this API, >>> i.e. the people who has made the API also made the console.dll. Both >>> the console.dll and the C++ API DLL is located in the same folder as >>> my interface.dll. But when using >>> ctypes.cdll.LoadLibrary("interface.dll") the loading fails. The error >>> reported is that a ceratin function cannot be found in the >>> console.dll. Using DependencyWalker to profile the loading of the >>> interface.dll I discovered that the LoadLibrary folder tries to load >>> console.dll found in C:\Windows\system32 instead of the console.dll >>> found in the same folder as interface.dll. >>> >>> Is this the wanted behaviour? Is there a way I can "help" the >>> LibraryLoader to find the right DLL? >> >> The strategy that LoadLibrary uses to find a dll is explained in the >> MSDN docs: >> >> http://msdn.microsoft.com/en-us/library/windows/desktop/ms684175%28v=vs.85%29.aspx >> >> Probably you should call LoadLibrary("console.dll"), maybe with the full >> path, before LoadLibrary("interface.dll"). >> >> Thomas >> >> >> ------------------------------------------------------------------------------ >> Virtualization & Cloud Management Using Capacity Planning >> Cloud computing makes use of virtualization - but cloud computing >> also focuses on allowing computing to be delivered as a service. >> http://www.accelacomm.com/jaw/sfnl/114/51521223/ >> _______________________________________________ >> ctypes-users mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/ctypes-users ------------------------------------------------------------------------------ Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/