Help with ctypes pointer return values

cantankerousoldgit at gmail.com cantankerousoldgit at gmail.com
Fri Sep 8 11:10:45 EDT 2006


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?




More information about the Python-list mailing list