Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > WindowsXP / CTypes Module - unable to access function in a dll

Reply
Thread Tools

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

 
 
dudeja.rajat@gmail.com
Guest
Posts: n/a
 
      08-19-2008
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?
 
Reply With Quote
 
 
 
 
Diez B. Roggisch
Guest
Posts: n/a
 
      08-19-2008
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WindowsXP/ CTypes - How to convert ctypes array to a string? dudeja.rajat@gmail.com Python 0 08-19-2008 10:20 AM
python - dll access (ctypes or swig) Daniel Watrous Python 9 04-19-2007 02:45 AM
RE: [ctypes-users] [Ann] ctypes 0.9.0 released Henk Punt Python 0 07-23-2004 10:34 PM
ctypes.com - unable to call function, read property Roman Yakovenko Python 0 04-14-2004 02:33 PM
msvcrt.dll, msvcirt.dll, msvcrt20.dll and msvcrt40.dll, explanation please! Snoopy NZ Computing 16 08-25-2003 12:34 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57