[python-win32] Problem passing a VARIANT argument to a method of aCOM object

Sumeet Sobti sumeet_sobti at yahoo.com
Wed Feb 8 01:37:35 CET 2006


Hi,

The authors of the COM object say that the failing
AddTest() method takes in an LPCSTR as its first
argument and a Variant as the second argument.

STDMETHODIMP CTTOrderSelector::AddTest(LPCSTR
lpProperty, VARIANT vValue)

LPCSTR is not a valid COM type, but somehow it is
correctly handled in C#. The authors claim that their
C# client code has been tested and is known to work
correctly.

Is there a hack that I can use through pywin to make
this work? Maybe call Invoke() for AddTest manually or
something?

Thanks!

-Sumeet.

--- Mark Hammond <mhammond at skippinet.com.au> wrote:

> At this stage the problem is more confusion as to
> exactly what is happening.
> My understanding is:
> 
> * Their type-library defines that method as having a
> variant type of
> VT_LPSTR.
> * Microsoft declares in wtypes.h that VT_LPSTR is
> valid in a typedesc, but
> *not* in a VARIANT.
> * When Python processes the typelib, it makes no
> attempt to translate
> VT_LPSTR to a type that is valid in a Variant.
> * When Python is making the call to the COM object,
> it sees that VT_LPSTR -
> but as it is filling a VARIANT, it gives that error
> (the error could be
> clearer - but that is the underlying reason for that
> type not being
> supported)
> 
> The last experiment I asked you to perform should
> have translated the
> VT_LPSTR from the typelib into a VT_BSTR - the
> "standard" string type - but
> that still failed.  You may also like to change the
> 30 to 12 (VT_VARIANT)
> and see if that helps.  But ultimately, I need to
> know exactly what variant
> type the COM object is expecting, and why it fails
> if a VT_BSTR variant is
> supplied.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Python-win32 mailing list