On 20-1-2012 21:14, Thomas Heller wrote: > Am 20.01.2012 15:50, schrieb Éric Piel: : > >> Would it be possible to modify comptypes to make it easier? >> * Could it be possible to have the tlb parser to detect this case and >> put the parameter as 'in' instead of 'out'? > > No. As I said in the thread that you mentioned, the tlb parser cannot > detect this case since the 'size_is()' info is simply not present in the > type library (the .tlb file). Yes. I looked more into details and I understand better. When a 'out pointer' is declared, in VB, you actually pass the variable as arguments, even if it's just a int, and you obtain the value by reading the variable after the call. But with comtypes, normally comtypes allocates the single int itself and you get the value as a return value. So in VB, getting an array works the same, while in comtypes it doesn't because comtypes just allocates a single element. Maybe one workaround would be to have an optional argument to specify the size of the allocation (with default of 1)?
> >> * Could it be possible to support the byref() construct like: >> c.GetImage(num_bytes, byref(buffer)) >> For now it raises a type exception: >> ArgumentError: argument 2:<type 'exceptions.TypeError'>: expected >> LP_c_ubyte instance instead of pointer to c_ubyte_Array_226304 > > I'm not sure about this. Does 'c.GetImage(num_bytes, buffer)' work? Ah! This one probably seemed too easy for me to try ;-) Indeed, it works, that's really clean :-) Thanks, Éric ------------------------------------------------------------------------------ Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2 _______________________________________________ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users