Out parameters to COM objects
Glenn Farrow
ghf at mailandnews.com
Thu May 25 23:21:51 EDT 2000
No problem instantiating COM objects and calling their methods in Python,
works great. But how do I call a function that requires a an OUT
parameter as opposed to returning a value.
(e.g.)
>>> import win32com.client
>>> ns =
>>> win32com.client.Dispatch('Netscape.Network.1')
>>> print ns
<COMObject Netscape.Network.1>
>>> bVal = ns.Open('www.cnn.com', 0, '',
<0, '')
>>> print bVal
1
Now I want to call "ns.Read(BSTR* pBuffer, short iAmount)", where this
method is expecting a BSTR pointing to a pre-allocated buffer of size
'iAmount'. How do I do this?
>>> sBuf = ''
>>> iRead = ns.Read(sBuf, 4096)
Traceback (innermost last):
File "<interactive input>", line 1, in ?
File "<COMObject
Netscape.Network.1>", line 2, in Read
com_error: (-2147352571, 'Type
mismatch.', None, 1)
More information about the Python-list
mailing list