I have created a COM server in Python 2.7 (using pythoncom) and would like to call it from C++ code, but I do not know how.
The Python COM server:
import pythoncom
class PyCOMTest:
_public_methods_ = ['getNextNum']
_reg_progid_ = "<some progid>"
_reg_clsid_ = "{<some hash string>}"
_reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER
numbb = 0
def __init__(self):
self.num = 0
def getNextNum(self):
print "method called"
PyCOMTest.numbb = PyCOMTest.numbb + 1
return PyCOMTest.numbb
if __name__ == '__main__':
print "Registering COM server..."
import win32com.server.register
win32com.server.register.UseCommandLine(PyCOMTest)
I am able to call the COM server using clients written in Python and another in VBScript.
I know that C++ requires an interface that extends IUnknown to call CoCreateInstance and QueryInterface on, but I want the COM server to be entirely in Python.
Any ideas?