Help with ctypes pointer return values

  • Thread starter cantankerousoldgit
  • Start date
C

cantankerousoldgit

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?
 
L

Lawrence Oluyede

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...
 
S

steve.horsley

Lawrence said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top