473,326 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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

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?
Aug 19 '08 #1
1 1570
du**********@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
Aug 19 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: zapazap | last post by:
Dear Snake Charming Gurus, (Was: http://mail.python.org/pipermail/python-list/2004-January/204454.html) First, a thank you to Tim Golden, Thomas Heller, and Mark Hammond for your earlier help...
1
by: Thomas Heller | last post by:
ctypes 0.9.1 released - Sept 14, 2004 ===================================== Overview ctypes is a ffi (Foreign Function Interface) package for Python 2.3 and higher. ctypes allows to call...
6
by: Mudcat | last post by:
Hi, I can't figure out why ctypes won't load the DLL I need to use. I've tried everything I can find (and the ctypes website is down at the moment). Here's what I've seen so far. I've added...
0
by: Egor Zindy | last post by:
Egor Zindy wrote: #!/usr/bin/env python """ A generic chipid library based on ctypes This module handles most of the functions in FTChipID.dll
5
by: castironpi | last post by:
Hi all, I have a mmap and a data structure in it. I know the structure's location in the mmap and what structure it is. It has a ctypes definition. I want to initialize a ctypes object to...
0
by: dudeja.rajat | last post by:
On Tue, Aug 19, 2008 at 11:04 AM, <dudeja.rajat@gmail.comwrote: Sorry, the problem is resolved. The code in fact is correct and I got the right answers. It is just that I was not priting results...
0
by: dudeja.rajat | last post by:
Hi, I've used CTYPES module to access a function from a dll. This function provides me the version of the dll. This information is accessible to me as an array of 4 long inetegers. information...
0
by: dudeja.rajat | last post by:
On Tue, Aug 19, 2008 at 12:20 PM, Fredrik Lundh <fredrik@pythonware.comwrote: Fredrik, My apology for any confusion created. I read all the replies. In fact I'm thankful to you all guys who are...
3
by: Paddy | last post by:
Hi, I am am falling at the first hurdle when trying to access a library using ctypes. I have a file libucdb.so which the file command says is shared object, but I cannot get it to load: Any...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.