WindowsXP / CTypes Module - unable to access function in a dll

Diez B. Roggisch deets at nospam.web.de
Tue Aug 19 06:10:21 EDT 2008


dudeja.rajat at gmail.com wrote:

> Hi,
> 
> I'm using the CTYPES module of python to load a dll. My dll contains a
> Get_Version function as:
> long __stdcall af1xEvdoRDll_GetVersion(long version[4]);
> 
> This function accepts a long array of 4 elements.
> 
> Following is the python code I've written:
> 
> from ctypes import *
> abc =  windll.af1xEvdoRDll
> GetVersion = abc.af1xEvdoRDll_GetVersion
> print GetVersion
> versionArr = c_long * 4                #array of 4 longs
> version = versionArr(0, 0, 0, 0)     # initializing all elements to 0
> GetVersion(version)                    #calling dll function
> print version
> 
> I'm getting the following output:
> <_FuncPtr object at 0x00A1EB70>
> <__main__.c_long_Array_4 object at 0x00A86300>
> 
> But I'm not getting the desired output which I expect as : 2.1.5.0
> 
> 
> Please suggest what am I missig?

Don't print the object, print it's contents:

for i in xrange(4):
    print version[i]

Might be that you can iterate over the array directly, not sure right now.

Diez



More information about the Python-list mailing list