473,401 Members | 2,127 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,401 software developers and data experts.

Help with ctypes pointer return values

I am trying to call a DLL with a function like this:

"""DESCRIPTION: Get a list of objects attributes matching
attribute values

ARGUMENTS:

session : [in] the current session

classId : [in] the class Id of objects owning attributes to
be returned

rec : [in] record initialized with attribute values
used as search parameters (initialized by user)

nbRecords : [out] number of returned records

recordList : [out] list of returned records

flags : [in] option flags

RETURN: IVAPI_OK if OK

NOTES: recordList must be deallocated via IVFreeRecordList.

If attListSize = 0, all the attributes will be retrieved

IMPORT int WINAPI IVQueryListByExample (IVSession session, unsigned
long classId, IVRecord rec, unsigned long* nbRecords, IVRecordList*
recordList, unsigned int flags);"""
It is the recordList variable I am having trouble with. Now, recordList
is a pointer to type IvRecordList, which is itself defined as a void*
in the header file like this:
typedef void *IVRecordList;
That makes recordList a type void**. I need to get the pointers out of
the list so I can pass them back to the API when querying the contents
of each record. I am getting nbRecords telling me that the function is
returning the number of records I expect, but I'm not sure how to
define IVRecordList when I pass it in so that I can extract the
pointers properly afterwards.

I've tried this, but the record pointers seem to have a value of None.

def IVQueryListByExample(session,classId,rec,flags):

nbRecords = ctypes.c_ulong()

recordList = ctypes.c_void_p()

status = ivapidll.IVQueryListByExample(session, classId, rec,
ctypes.byref(nbRecords), ctypes.byref(recordList), flags)
Does anyone have a good idea how I should define recordList so that I
can retrieve the record pointers?

Sep 8 '06 #1
2 2308
<ca****************@gmail.comwrote:
Does anyone have a good idea how I should define recordList so that I
can retrieve the record pointers?
POINTER(POINTER(c_void)) ?

Maybe I misunderstood tough...

--
Lawrence - http://www.oluyede.org/blog
"Nothing is more dangerous than an idea
if it's the only one you have" - E. A. Chartier
Sep 8 '06 #2

Lawrence Oluyede wrote:
<ca****************@gmail.comwrote:
Does anyone have a good idea how I should define recordList so that I
can retrieve the record pointers?

POINTER(POINTER(c_void)) ?

Maybe I misunderstood tough...
That's interesting. It had not occurred to me that you could do that.
And I also read that you can index pointers with pointer[x], so I think
that will do the trick.

Thanks for the pointer <groan>. I'll give it a try ASAP.

The Cog.

Sep 11 '06 #3

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

Similar topics

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...
3
by: p.lavarre | last post by:
Subject: Python CTypes translation of (pv != NULL) And so then the next related Faq is: Q: How should I test for ((void *) -1)? A: (pv == 0xffffFFFF) works often.
1
by: sjdevnull | last post by:
Hey, I'm trying to wrap GNU readline with ctypes (the Python readline library doesn't support the callback interface), but I can't figure out how to set values to a variable inside the library. ...
0
by: chris.atlee | last post by:
Hello, I've been trying to write a PAM module using ctypes. In the conversation function (my_conv in the script below), you're passed in a pam_response** pointer. You're supposed to allocate...
3
by: Chris AtLee | last post by:
Sorry for the repeat post...I'm not sure if my first post (on May 30th) went through or not. I've been trying to write a PAM module using ctypes. In the conversation function (my_conv in the...
6
by: Jack | last post by:
I'm not able to build IP2Location's Python interface so I'm trying to use ctypes to call its C interface. The functions return a pointer to the struct below. I haven't been able to figure out how...
1
by: gianluca | last post by:
hy, I've a huge problem with ctypes. I've compiled my C library and I'd like use it in python with ctype. One function need to pass a pointer to typed ( like this: typedef int value_type). In...
2
by: Jean-Paul Calderone | last post by:
On Mon, 30 Jun 2008 09:13:42 -0700 (PDT), gianluca <geonomica@gmail.comwrote: POINTER takes a class and returns a new class which represents a pointer to input class. pointer takes an instance...
4
by: taghi | last post by:
I want to call NetShareEnum, a function from netapi32.dll NetShareEnum has this definition: NET_API_STATUS NetShareEnum( __in LPWSTR servername, __in DWORD level, __out LPBYTE...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.