ctypes DLL with optional dependencies

Posted by pisswillis on Stack Overflow See other posts from Stack Overflow or by pisswillis
Published on 2010-05-26T15:52:07Z Indexed on 2010/05/26 16:21 UTC
Read the original article Hit count: 196

Filed under:
|
|
|
|

Disclaimer: I'm new to windows programming so some of my assumptions may be wrong. Please correct me if so.

I am developing a python wrapper for a C API using ctypes. The API ships with both 64 and 32 DLLs/LIBs. I can succesfully load the DLL using ctypes.WinDLL('TheLibName') and call functions etc etc.

However some functions were not doing what they should. Upon further investigation it appears that the 32bit DLL is being used, which is what is causing the unexpected behaviour.

I have tried using ctypes.WinDLL('TheLibName64') but the module is not found. I have tried registering the DLL with regsrv32, but it reports there is no entry point (it also reports no entry point when I try and register TheLibName, which is found by WinDLL().

The DLL came with a sample project in Visual Studio (I have 0 experience with VS so again please correct me here) which builds both 32 and 64 bit versions of the sample project. In the .vcsproj file the configurations for the 64 bit version include:

AdditionalDependencies="TheLibName64.lib"

in the VCLinkerTool section.

In windows/system32 there are both TheLibName.dll/.lib, and TheLibName64.dll/.lib.

So it seems to me that my problem is now to make the python ctypes DLL loader load these optional dependencies when the DLL is loaded. However I can't find any information on this (perhaps because, as a doze noob, I do not know the correct terminology) in the ctypes documentation.

Is there a way to do this in ctypes? Am I going about this in completely the wrong way? Any help or general information about optional DLL dependencies and how they are loaded in windows would be much appreciated.

Thanks

© Stack Overflow or respective owner

Related posts about python

Related posts about Windows