By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,028 Members | 1,945 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,028 IT Pros & Developers. It's quick & easy.

Help with ctypes pointer return values

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
<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

P: n/a

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 discussion thread is closed

Replies have been disabled for this discussion.