ctypes listing dll functions
Tim Roberts
timr at probo.com
Sat Sep 9 02:16:21 EDT 2006
marc.wyburn at googlemail.com wrote:
>
>hi all and before I start I apologise if I have this completely muddled
>up but here goes.
>
>I'm trying to call functions from a dll file in a python script but I
>can't work out what functions are available. I'm using ctypes. I've
>tried using dir(ctypes_object) but the resultant output looks like a
>list of standard functions and not the ones I'm looking for.
As far as I know, there is no way with ctypes to enumerate the functions
exported by a DLL. If you have Visual C++, you can use link.exe to do
this:
link /dump /exports xxxxx.dll
>Also how can I tell if the dll was written in C or C++ as I understand
>C++ dlls can't be used.
Well, DLLs that use C++ features cannot be used. If the exported names are
"decorated", then they can't be used.
>I have a header file that starts;
>
>#ifndef __DIRAC__
>#define __DIRAC__
>
> // Prototypes
>
> const char *DiracVersion(void);
> void *DiracCreate(long lambda, long quality, long numChannels,
>float sampleRate, long (*readFromChannelsCallback)(float **data, long
>numFrames, void *userData));
> void *DiracCreate(long lambda, long quality, long numChannels,
>float sampleRate, long (*readFromChannelsCallback)(float *data, long
>numFrames, void *userData));
That's called "function overloading": two functions with the same name but
slightly different parameters. That is only available with C++, so I'm
afraid you are out of luck. You may be able to use SWIG to generate an
interface for this; I've had good luck with SWIG.
--
- Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list