[python-win32] Python, COM, VARIANT, VT_BYREF, Joy!

George Doster docdoster at gmail.com
Tue May 25 00:43:27 CEST 2010


On Mon, May 24, 2010 at 8:25 AM, Mark Hammond <skippy.hammond at gmail.com>wrote:

> On 22/05/2010 12:15 AM, George Doster wrote:
>
>> Hello All,
>>
>> I'm trying to write a Python program that uses a provided ActiveX
>> component. I have verified the component works ok with Visual Basic.
>>
>> I have used makepy to build the import module for my ActiveX component.
>>
>> I can successfully load the component via the ActiveXCtrl class found in
>> wxPython.
>>
>> My issue is how to call one of the methods of the ActiveX component. The
>> method requires a pointer to a variant.
>>
>> Excerpt from the makepy created module:
>>
>> def OpenUSB(self, lWarning=
>> defaultNamedNotOptArg):
>>         return self._oleobj_.InvokeTypes(1, LCID, 1, (3, 0), ((16387,
>> 0),),lWarning)
>>
>> As you can see, the first arg is a VT_BYREF | VT_I4.
>>
>
> You should find that you don't need to supply the argument at all -
> win32com should initialize and provide the param for you and return the
> final result in the return value - assuming the param is an 'out' param.
>
> Cheers,
>
> Mark
>

Hi Mark,

On calling OpenUSB with no argument I get:

Traceback (most recent call last):
  File "pyNovaII_new.py", line 22, in OnTest
    print app.OphirCtrl.ctrl.OpenUSB()
  File "C:\Python26\lib\site-packages\comtypes\__init__.py", line 517, in
func
    return self.Invoke(obj, memid, _invkind=1, *args, **kw) #
DISPATCH_METHOD
  File "C:\Python26\lib\site-packages\comtypes\automation.py", line 710, in
Invoke
    byref(result), byref(excepinfo), byref(argerr))
_ctypes.COMError: (-2147352561, 'Parameter not optional.', (None, None,
None, 0, None))


Parameter no optional.... :(

J
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20100524/10f47262/attachment.html>


More information about the python-win32 mailing list