win32com

F

floris.vannee

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
 
F

floris.vannee

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("Python.TestServer") 'Python.TestServer 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top