win32com

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • floris.vannee@gmail.com

    #1

    win32com

    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.TestSer ver"

    # 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__=='__ma in__':
    import win32com.server .register
    win32com.server .register.UseCo mmandLine(Hello World)


    When I run it it says: '>>> Registered: Python.TestServ er '

    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

  • Méta-MCI

    #2
    Re: win32com

    Hi!

    Answer in the mailing-list.

    @-salutations

    Michel Claveau



    Comment

    • floris.vannee@gmail.com

      #3
      Re: win32com

      Thanks :)

      For people who are also having this problem. The VB .NET code to import
      that COM object is:
      dim com_object as object
      com_object = CreateObject("P ython.TestServe r") 'Python.TestSer ver in
      this case, but for different programs, different names of course.

      And in order to get it work you need to remove this code of python
      line:
      _reg_desc_ = "Python Test COM Server"

      I dont know why, but it didn't work with that line, and it did work
      without the line.

      Floris

      Comment

      Working...