win32com: Setting ByRef parameters in an event

Paul Moore paul.moore at uk.origin-it.com
Thu Aug 23 10:03:26 EDT 2001


On Fri, 17 Aug 2001 14:51:00 +0200, Paul Moore <paul.moore at uk.origin-it.com>
wrote:

>>It should :(  The Excel etc demos all work fine with very similar 
>>constructs.  You could try:
>>
>>    return 1==1
>>
>>which due to an implementation detail will ensure that a VT_BOOL is 
>>returned - however, this should not be necessary.
>
>Nope, that din't fix it. Looks like it might be a bug in the component. But as
>it works fine from VBScript and Perl (JavaScript can't handle ByRef
>parameters, so I can't try that), I'm not sure how much chance I have of
>getting the developer to care... :-(

I got a code snippet from the developer, and the component does check VT_BOOL.
I'll ask him to change that.

Now, I find that

    return 1, 1==1

works. Looks like the WakeUp parameter is being set from the *second* return
value. And yet the IDL shows

>
>        HRESULT OnTick(
>                        [in] VARIANT RemainingTime, 
>                        [in, out] VARIANT* WakeUp);
>

Which, if I understand the win32com stuff (which I don't!!!) should mean that
WakeUp gets set from the *first* return value, not the second. Where did the
first value go?

Am I misunderstanding here? With a normal method, the return value is a tuple
consisting of the [out, retval] value first, followed by any other [out]
parameters. But for an event, there isn't a [retval] parameter, and it's the
component calling us, not the other way around. Could that make a difference?
I tried to follow the DispatchWithEvents code, but it's totally beyond me...

Paul.

PS I don't see a specific PyVARIANT (or whatever) type in the COM support
stuff. It might be nice to have, for cases where a component *requires* a
particular variant type, or something equally obscure...




More information about the Python-list mailing list