MCPcopy Create free account
hub / github.com/ActiveState/code / __init__

Method __init__

recipes/Python/577654_DDE_Client/recipe-577654.py:132–150  ·  view source on GitHub ↗

Create a connection to a service/topic.

(self, service, topic)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

DDEErrorClass · 0.85
InitializeMethod · 0.80
ConnectMethod · 0.80

Tested by

no test coverage detected