return struct in ctypes

James Hu jhu at metrigenix.com
Thu Oct 6 03:35:01 CEST 2005


hi,
 
I need to use ctypes to call the API function like
 
fun1(&list, listLen)              //here  list is struct { long id; long type; long isOpen;}  ListItem;
 
so I define

class LIST_ITEM(Structure):
    _fields_ = [("Id", c_ulong),
                ("Type",c_ulong ),   
                ("isOpen", c_ulong),               
                ]
 
list=LIST_ITEM()
listLen=c_ulong(1)
thedriver.fun1(byref(list),listLen)
doesn't work, here the list is input param, not return info.
 
if use 
list=c_char_p()
thedriver.fun1(byref(list),listLen)
 
how can I convert the list to LIST_ITEM?
 
another Q is :
how to use ctypes to implement this:
 
  struct1 mySettings;                              // here struct1 {long size; long params[32];}
   mySettings.size = sizeof(mySettings); 
 
Where can get ctypes good samples? the samples with the package seems very simple. and the ctypes tutorial doesn't handle these cases either.
 
Thanks in advance
 
James
 
 
 
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20051005/01e0a3d5/attachment.html>


More information about the Python-list mailing list