win32com

floris.vannee at gmail.com floris.vannee at gmail.com
Fri Apr 7 12:58:19 EDT 2006


Hi,

Is it possible to create a com server in python and then access that
server using VB .NET, for example using the following code. A very
basic com server i found in a tutorial about win32com:

class HelloWorld:
    _reg_clsid_ = "{7CC9F362-486D-11D1-BB48-0000E838A65F}"

    _reg_desc_ = "Python Test COM Server"

    _reg_progid_ = "Python.TestServer"

    # Next line assumes file is "testcomserver.py"

    _reg_class_spec_ = "testcomserver.HelloWorld"

    _public_methods_ = ['Hello']

    _public_attrs_ = ['softspace', 'noCalls']

    _readonly_attrs_ = ['noCalls']

    def __init__(self):
        self.softspace = 1

        self.noCalls = 0

    def Hello(self, who):

        self.noCalls = self.noCalls + 1

        # insert "softspace" number of spaces

        return "Hello" + " " * self.softspace + who

if __name__=='__main__':
    import win32com.server.register
    win32com.server.register.UseCommandLine(HelloWorld)


When I run it it says: '>>>  Registered: Python.TestServer '

But how can I access that server now from VB .NET (if it's possible).
Or do I need to use very different python code? (I wasnt sure where to
put this, in vb or python section, sorry if its in the wrong section)

Thanks in advance,

Floris van Nee




More information about the Python-list mailing list