469,282 Members | 1,732 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

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.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

Apr 7 '06 #1
2 2105
Hi!

Answer in the mailing-list.

@-salutations

Michel Claveau

Apr 7 '06 #2
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

Apr 7 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Justin Stockton | last post: by
3 posts views Thread by RJ | last post: by
reply views Thread by Paul McGuire | last post: by
2 posts views Thread by Sibylle Koczian | last post: by
12 posts views Thread by vithi | last post: by
2 posts views Thread by Ray | last post: by
11 posts views Thread by Bill Davy | last post: by
4 posts views Thread by sterling | last post: by
2 posts views Thread by RyanN | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.