Win32-COM pass by ref for long arguments

vng1 at vng1 at
Sat Sep 25 17:05:09 CEST 2004

I figured it out eventually.  It wasn't  clear from any of the 
Python/COM documentation that pass byref variables are returned as 
'extra' values in the return value.

So a COM function like:

Function OpenTable(ByRef hTableRef As Long, ByVal TableNo As Long) As 

becomes translated to this:

def OpenTable( discardedhTableRef, tableNo):
	# COM bridge does stuff here
	return (boolResult, hTableRef)

Well - it wasn't obvious to _me_ anyway.


On 24-Sep-04, at 04:16 PM, Stephen Prinster wrote:

> Victor Ng wrote:
>> My call is using an initial value of pythoncom.Empty for hTableRef,
>> but I'm getting the following stacktrace from within the PythonCOM
>> library:
> Have you tried pythoncom.Missing instead of pythoncom.Empty?  I don't 
> know what the difference is, but I remember seeing a comment in a 
> makepy-generated file about trying both because sometimes one works 
> better than the other.
> -- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3901 bytes
Desc: not available
URL: <>

More information about the Python-list mailing list