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

mark ferguson markferg at gmail.com
Thu Aug 26 16:54:42 CEST 2010


On 26 August 2010 02:35, Mark Hammond <skippy.hammond at gmail.com> wrote:

> ...
> import generated_file # the makepy generated file.
> lr = win32com.client.Dispatch("wlrun.LrEngine")
> lr = generated_file.LrEngine(lr) # wrap it.
> ...
> The above assumes the class name in the generated file is also LrEngine.
> ...
> Note that even then, to get reasonable byref behaviour the IDL file for the
> object will need to have specified the "in/out" semantics correctly.
>
> HTH,
>
> Mark
>

Thanks for the input Mark. I've got a workaround doing the above and also
editing the makepy generated file. The problem seems to be that Get...
methods pass the ByRef parameter when it is not needed. Rather than changing
everything, I'm just changing methods as and when I need them. For example:

#    def GetVuserTypeLicenseLimit(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)
    def GetVuserTypeLicenseLimit(self, strVuserType=defaultNamedNotOptArg):
        """Get the License limit for the Vuser Type """
        return self._oleobj_.InvokeTypes(8, LCID, 1, (3, 0), ((8, 1),
(16387, 0)),strVuserType )*
*
Then I can use:
import win32com.client
import lrcontroller # the makepy generated file, renamed and put in
site-packages

lr = win32com.client.Dispatch("wlrun.LrEngine")
lr = lrcontroller.LrEngine(lr) # wrap it.
lr.ShowMainWindow(True) # <- works fine, application pops up ok.
status, webVusers = lr.GetVuserTypeLicenseLimit("Web & Multimedia Bundle") #
<:-)
print webVusers

Maybe not the most elegant solution, but it does the job!

Mark.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20100826/7be43862/attachment.html>


More information about the python-win32 mailing list