[python-win32] python COM-Server and VBScript
Frank Günther
f.g.- at gmx.de
Fri Jun 23 07:12:03 CEST 2006
Hi all,
I found a strange behaviour when I use a python-COM-Server together with VB.
It seems that the first argument of a COM-Method that is passed by a
VB-variable is set to VB-Nothing after the Method call.
For example if I use the code below: After calling
testSrvObj.SetValue what, value
what is deleted, but not value. But after calling
testSrvObj.SetValue "ABC", value
value is deleted.
Has anybody an idea what is the problem?
Ciao,
Frank
------------------testcall.vbs----------------------------------
Dim testSrvObj, what, value, retvalue
Set testSrvObj = CreateObject("TestSrv.Application")
value = "ABCValue"
what = "ABC"
msgbox("before: what ="& what & " value ="& value)
testSrvObj.SetValue what, value
msgbox("after1: what ="& what & " value ="& value)
testSrvObj.SetValue "ABC", value
msgbox("after2: value ="& value)
retvalue = testSrvObj.GetValue("ABC")
msgbox("retvalue="& retvalue)
------------------testcall.vbs---------------------------------
-------------------testsrve.py--------------------------------
import pythoncom
class TestSrv(object):
_reg_clsid_ = '{C7B89AAC-99B7-48A1-8088-D77A867CBB0C}'
_reg_desc_ = 'TestSrv COM+ Server'
_reg_progid_ = 'TestSrv.Application'
_reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER
_public_methods_ = ['SetValue', 'GetValue']
def __init__(self):
self.ABC = ''
def SetValue(self, what, newval):
if what == 'ABC':
self.ABC = newval
def GetValue(self, what):
if what == 'ABC':
return self.ABC
if __name__=='__main__':
import win32com.server.register
win32com.server.register.UseCommandLine(TestSrv, debug=0)
-------------------testsrve.py--------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20060623/2c9b67db/attachment.htm
More information about the Python-win32
mailing list