[python-win32] in-process COM DLL in Python
Wuping Xin
oudouxin at gmail.com
Sat Apr 15 21:50:31 EDT 2023
Forget it. I figured it our by looking into Chapter 12 of the Book -
Python Programming On Win32. What a Bible it is.
Cheers.
------ Original Message ------
>From "Wuping Xin" <oudouxin at gmail.com>
To python-win32 at python.org
Date 4/15/2023 5:27:47 PM
Subject in-process COM DLL in Python
>I'd like to return another Python object, using a method of a COM
>object defined using Python, something like below - is that doable?
>For in process COM object defined through Python, is there any
>limitation about the types that can be returned from COM method?
>
>class Person:
> _public_methods_ = ["Name"]
>
> def __init__(self, name, age):
> self.name = name
> self.age = age
>
> def Name(self, age = None):
> return self.name
>
>
># Define a Python class that will be registered as a COM object
>class MyCOMObject:
> _public_methods_ = ["GetPerson"]
>
> def GetPerson(self, name, age):
> p = Person(name, age)
> my_variant = pywintypes.VARIANT(p, VARIANT.VT_DISPATCH)
> return my_variant
>
># Register the class as a COM object
>
>win32com.server.register.UseCommandLine(MyCOMObject)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/python-win32/attachments/20230416/d44b7544/attachment-0001.html>
More information about the python-win32
mailing list