Am 20.01.2012 15:50, schrieb Éric Piel:
> Hello,
>
> I'm in a similar situation of what was described previously in this thread:
> http://sourceforge.net/mailarchive/message.php?msg_id=25175351
>
> I need to send a pointer to a buffer which will be filled by the method
> as output. The IDL looks like this:
> HRESULT GetImage([in] long lSize, [out, size_is(size)] BYTE *pbImage)
>
> With the SVN head of comtypes, it's fairly easy to handle, but I still
> need to do two things:
> * Change the generated python class to force pbImage to be 'in' and not
> 'out'
> * Cast my buffer variable to look like a pointer to a byte, and not an
> array:
>     buffer = (c_ubyte * num_bytes)()
>     c.GetImage(num_bytes, cast(pointer(buffer), POINTER(c_ubyte)))
>
> So my question: is this the right way to do it?

Yes, it seems so.  If it works, I can't test this now.

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

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

Thomas


------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
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-d2d
_______________________________________________
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users

Reply via email to