[python-win32] Client side COM problems with ByRef parameters

mark ferguson markferg at gmail.com
Tue Aug 24 15:56:06 CEST 2010


I'm trying to drive an application via it's COM interface but I am having
trouble with ByRef parameters.

The method I'm having trouble with, in VB, is:
Public Function GetVuserTypeLicenseLimit( ByVal strVuserType As String,
ByRef pRetLimit As Long ) As Long

translating this into python as:
a = o.GetVuserTypeLicenseLimit("userType")

gives me:

com_error: (-2147352561, 'Parameter not optional.', None, None)

Now, I played about with the .py file generated by makepy to see if I could
persuade it to play nicely but nothing affected the result. Eventually I
changed the .py file so that the interface was:

    def xxGetVuserTypeLicenseLimit(self, strVuserType=defaultNamedNotOptArg,
pRetLimit=defaultNamedNotOptArg):
        """Get the License limit for the Vuser Type """
        return self._oleobj_.InvokeTypes(8, LCID, 1, (3, 0), ((8, 1),
(16387, 0)),strVuserType
            , pRetLimit)

and it still didn't change anything! I'd have expected an 'Attribute Error'
or something like that as I've changed the method name. As a last resort I
deleted the contents of the gen_py directory, still with no effect. So, I'm
left thinking that this type lib can't or won't use the win32com magic
Dispatch support and it's falling back to dynamic support. Can anyone
suggest what's actually happening here, and any way forward?

For completeness, the entire script is:

import win32com.client
lr = win32com.client.Dispatch("wlrun.LrEngine")
lr.ShowMainWindow(True) # <- works fine, application pops up ok.
webVusers = lr.GetVuserTypeLicenseLimit("QTWeb") # <:-(
print webVusers


Thanks,

Mark.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20100824/8e54f3c9/attachment.html>


More information about the python-win32 mailing list