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

Fredrik Lundh fredrik at pythonware.com
Tue Aug 19 12:15:24 CEST 2008


dudeja.rajat at gmail.com wrote:

> 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

expecting that Python/ctypes should be able to figure out that you
want an array of 4 integers printed as a dot-separated string is a
bit optimistic, perhaps.  but nothing that a little explicit string 
formatting cannot fix:

 >>> from ctypes import *
 >>> versionArr = c_long * 4
 >>> version = versionArr(1, 2, 3, 4)
 >>> "%d.%d.%d.%d" % tuple(version)
'1.2.3.4'

</F>




More information about the Python-list mailing list