Request data from DDE service.
(self, item, timeout=5000)
| 177 | DDE.FreeDataHandle(hDdeData) |
| 178 | |
| 179 | def request(self, item, timeout=5000): |
| 180 | """Request data from DDE service.""" |
| 181 | from ctypes import byref |
| 182 | |
| 183 | hszItem = DDE.CreateStringHandle(self._idInst, item, 1200) |
| 184 | hDdeData = DDE.ClientTransaction(LPBYTE(), 0, self._hConv, hszItem, CF_TEXT, XTYP_REQUEST, timeout, LPDWORD()) |
| 185 | DDE.FreeStringHandle(self._idInst, hszItem) |
| 186 | if not hDdeData: |
| 187 | raise DDEError("Unable to request item", self._idInst) |
| 188 | |
| 189 | if timeout != TIMEOUT_ASYNC: |
| 190 | pdwSize = DWORD(0) |
| 191 | pData = DDE.AccessData(hDdeData, byref(pdwSize)) |
| 192 | if not pData: |
| 193 | DDE.FreeDataHandle(hDdeData) |
| 194 | raise DDEError("Unable to access data", self._idInst) |
| 195 | # TODO: use pdwSize |
| 196 | DDE.UnaccessData(hDdeData) |
| 197 | else: |
| 198 | pData = None |
| 199 | DDE.FreeDataHandle(hDdeData) |
| 200 | return pData |
| 201 | |
| 202 | def callback(self, value, item=None): |
| 203 | """Calback function for advice.""" |
no test coverage detected