Win32 COM: Passing NULL as a value
aleaxit at yahoo.com
Sat Feb 17 08:48:23 CET 2001
"Mark Hammond" <MarkH at ActiveState.com> wrote in message
news:3A8DBDC4.4040705 at ActiveState.com...
> William Wicker wrote:
> > I am trying to work via the COM interface to an object that exposes a
> > method something like this:
> > AnObject.DoSomething(doWhat, toWho)
> > where toWho is either a dispatch pointer, or NULL, if toWho is not
> > significant.
> > When I try to do this with
> > obj = win32com.client.Dispatch("AnObject")
> > obj.DoSomething("kick", None)
> None is used to pass a variant with VT_NULL. It works for every object I
have come across, so I am afraid I have no idea.
If the AnObject used canonical API's to handle its arguments
(VariantChangeType, directly or under the covers) it should
indeed work -- a VariantChangeType from VT_NULL to VT_DISPATCH
should succeed and give a VARIANT with pdispVal of 0. So, I
guess from the symptoms described that AnObject is not being
'canonical' in its handling of arguments.
Is there a way to prepare a VARIANT directly in Python, with
VT_DISPATCH and pdispVal==0? When met with such issues
in the past I used a little helper, an in-process COM server I
wrote that supplies a few objects for explicit fine-grained
issues of Automation ("prepare a variant with exactly this vt
tag-part and exactly this bitpattern in its value-union part"
being a good example). But Pythoncom looks like it's powerful
enough to handle it directly if one digs deep enough, rather
than needing an auxiliary C++ coded library of objects...?
More information about the Python-list