Create a connection to a service/topic.
(self, service, topic)
| 130 | classbacks subclass DDEClient and overwrite callback.""" |
| 131 | |
| 132 | def __init__(self, service, topic): |
| 133 | """Create a connection to a service/topic.""" |
| 134 | from ctypes import byref |
| 135 | |
| 136 | self._idInst = DWORD(0) |
| 137 | self._hConv = HCONV() |
| 138 | |
| 139 | self._callback = DDECALLBACK(self._callback) |
| 140 | res = DDE.Initialize(byref(self._idInst), self._callback, 0x00000010, 0) |
| 141 | if res != DMLERR_NO_ERROR: |
| 142 | raise DDEError("Unable to register with DDEML (err=%s)" % hex(res)) |
| 143 | |
| 144 | hszService = DDE.CreateStringHandle(self._idInst, service, 1200) |
| 145 | hszTopic = DDE.CreateStringHandle(self._idInst, topic, 1200) |
| 146 | self._hConv = DDE.Connect(self._idInst, hszService, hszTopic, PCONVCONTEXT()) |
| 147 | DDE.FreeStringHandle(self._idInst, hszTopic) |
| 148 | DDE.FreeStringHandle(self._idInst, hszService) |
| 149 | if not self._hConv: |
| 150 | raise DDEError("Unable to establish a conversation with server", self._idInst) |
| 151 | |
| 152 | def __del__(self): |
| 153 | """Cleanup any active connections.""" |
nothing calls this directly
no test coverage detected