1 /**
2  * Windows API header module
3  *
4  * Translated from MinGW Windows headers
5  *
6  * Authors: Stewart Gordon
7  * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
8  * Source: $(DRUNTIMESRC core/sys/windows/_ddeml.d)
9  */
10 module core.sys.windows.ddeml;
11 version (Windows):
12 
13 version (ANSI) {} else version = Unicode;
14 pragma(lib, "user32");
15 
16 import core.sys.windows.basetsd, core.sys.windows.windef, core.sys.windows.winnt;
17 
18 mixin DECLARE_HANDLE!("HCONVLIST");
19 mixin DECLARE_HANDLE!("HCONV");
20 mixin DECLARE_HANDLE!("HSZ");
21 mixin DECLARE_HANDLE!("HDDEDATA");
22 
23 enum : int {
24     CP_WINANSI    = 1004,
25     CP_WINUNICODE = 1200
26 }
27 
28 enum : UINT {
29     XTYPF_NOBLOCK = 2,
30     XTYPF_NODATA  = 4,
31     XTYPF_ACKREQ  = 8
32 }
33 
34 enum : UINT {
35     XCLASS_MASK         = 0xFC00,
36     XCLASS_BOOL         = 0x1000,
37     XCLASS_DATA         = 0x2000,
38     XCLASS_FLAGS        = 0x4000,
39     XCLASS_NOTIFICATION = 0x8000
40 }
41 
42 enum : UINT {
43     XST_NULL,
44     XST_INCOMPLETE,
45     XST_CONNECTED,
46     XST_INIT1,
47     XST_INIT2,
48     XST_REQSENT,
49     XST_DATARCVD,
50     XST_POKESENT,
51     XST_POKEACKRCVD,
52     XST_EXECSENT,
53     XST_EXECACKRCVD,
54     XST_ADVSENT,
55     XST_UNADVSENT,
56     XST_ADVACKRCVD,
57     XST_UNADVACKRCVD,
58     XST_ADVDATASENT,
59     XST_ADVDATAACKRCVD // = 16
60 }
61 
62 enum : UINT {
63     XTYP_ERROR           = XCLASS_NOTIFICATION | XTYPF_NOBLOCK,
64     XTYP_ADVDATA         = 0x0010 | XCLASS_FLAGS,
65     XTYP_ADVREQ          = 0x0020 | XCLASS_DATA | XTYPF_NOBLOCK,
66     XTYP_ADVSTART        = 0x0030 | XCLASS_BOOL,
67     XTYP_ADVSTOP         = 0x0040 | XCLASS_NOTIFICATION,
68     XTYP_EXECUTE         = 0x0050 | XCLASS_FLAGS,
69     XTYP_CONNECT         = 0x0060 | XCLASS_BOOL | XTYPF_NOBLOCK,
70     XTYP_CONNECT_CONFIRM = 0x0070 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK,
71     XTYP_XACT_COMPLETE   = 0x0080 | XCLASS_NOTIFICATION,
72     XTYP_POKE            = 0x0090 | XCLASS_FLAGS,
73     XTYP_REGISTER        = 0x00A0 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK,
74     XTYP_REQUEST         = 0x00B0 | XCLASS_DATA,
75     XTYP_DISCONNECT      = 0x00C0 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK,
76     XTYP_UNREGISTER      = 0x00D0 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK,
77     XTYP_WILDCONNECT     = 0x00E0 | XCLASS_DATA | XTYPF_NOBLOCK,
78     XTYP_MONITOR         = 0X00F0 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK,
79     XTYP_MASK            = 0x00F0,
80     XTYP_SHIFT           = 4
81 }
82 
83 enum : UINT {
84     TIMEOUT_ASYNC = 0xFFFFFFFF
85 }
86 
87 enum : UINT {
88     QID_SYNC      = 0xFFFFFFFF
89 }
90 
91 enum : UINT {
92     ST_CONNECTED  =   1,
93     ST_ADVISE     =   2,
94     ST_ISLOCAL    =   4,
95     ST_BLOCKED    =   8,
96     ST_CLIENT     =  16,
97     ST_TERMINATED =  32,
98     ST_INLIST     =  64,
99     ST_BLOCKNEXT  = 128,
100     ST_ISSELF     = 256
101 }
102 
103 enum : UINT {
104     CADV_LATEACK  = 0xFFFF
105 }
106 
107 enum : UINT {
108     DMLERR_NO_ERROR      = 0,
109     DMLERR_FIRST         = 0x4000,
110     DMLERR_ADVACKTIMEOUT = DMLERR_FIRST,
111     DMLERR_BUSY,
112     DMLERR_DATAACKTIMEOUT,
113     DMLERR_DLL_NOT_INITIALIZED,
114     DMLERR_DLL_USAGE,
115     DMLERR_EXECACKTIMEOUT,
116     DMLERR_INVALIDPARAMETER,
117     DMLERR_LOW_MEMORY,
118     DMLERR_MEMORY_ERROR,
119     DMLERR_NOTPROCESSED,
120     DMLERR_NO_CONV_ESTABLISHED,
121     DMLERR_POKEACKTIMEOUT,
122     DMLERR_POSTMSG_FAILED,
123     DMLERR_REENTRANCY,
124     DMLERR_SERVER_DIED,
125     DMLERR_SYS_ERROR,
126     DMLERR_UNADVACKTIMEOUT,
127     DMLERR_UNFOUND_QUEUE_ID, // = 0x4011
128     DMLERR_LAST          = DMLERR_UNFOUND_QUEUE_ID
129 }
130 
131 enum : UINT {
132     DDE_FACK            = 0x8000,
133     DDE_FBUSY           = 0x4000,
134     DDE_FDEFERUPD       = 0x4000,
135     DDE_FACKREQ         = 0x8000,
136     DDE_FRELEASE        = 0x2000,
137     DDE_FREQUESTED      = 0x1000,
138     DDE_FAPPSTATUS      = 0x00ff,
139     DDE_FNOTPROCESSED   = 0,
140     DDE_FACKRESERVED    = (~(DDE_FACK|DDE_FBUSY|DDE_FAPPSTATUS)),
141     DDE_FADVRESERVED    = (~(DDE_FACKREQ|DDE_FDEFERUPD)),
142     DDE_FDATRESERVED    = (~(DDE_FACKREQ|DDE_FRELEASE|DDE_FREQUESTED)),
143     DDE_FPOKRESERVED    = (~DDE_FRELEASE)
144 }
145 
146 enum : UINT {
147     MSGF_DDEMGR         = 0x8001
148 }
149 
150 enum CBR_BLOCK = cast(HDDEDATA)-1;
151 
152 enum DWORD
153     APPCLASS_STANDARD         = 0,
154     APPCLASS_MONITOR          = 0x00000001,
155     APPCLASS_MASK             = 0x0000000F,
156     APPCMD_CLIENTONLY         = 0x00000010,
157     APPCMD_FILTERINITS        = 0x00000020,
158     APPCMD_MASK               = 0x00000FF0,
159     CBF_FAIL_SELFCONNECTIONS  = 0x00001000,
160     CBF_FAIL_CONNECTIONS      = 0x00002000,
161     CBF_FAIL_ADVISES          = 0x00004000,
162     CBF_FAIL_EXECUTES         = 0x00008000,
163     CBF_FAIL_POKES            = 0x00010000,
164     CBF_FAIL_REQUESTS         = 0x00020000,
165     CBF_FAIL_ALLSVRXACTIONS   = 0x0003f000,
166     CBF_SKIP_CONNECT_CONFIRMS = 0x00040000,
167     CBF_SKIP_REGISTRATIONS    = 0x00080000,
168     CBF_SKIP_UNREGISTRATIONS  = 0x00100000,
169     CBF_SKIP_DISCONNECTS      = 0x00200000,
170     CBF_SKIP_ALLNOTIFICATIONS = 0x003c0000,
171     MF_HSZ_INFO               = 0x01000000,
172     MF_SENDMSGS               = 0x02000000,
173     MF_POSTMSGS               = 0x04000000,
174     MF_CALLBACKS              = 0x08000000,
175     MF_ERRORS                 = 0x10000000,
176     MF_LINKS                  = 0x20000000,
177     MF_CONV                   = 0x40000000,
178     MF_MASK                   = 0xFF000000;
179 
180 enum : UINT {
181     EC_ENABLEALL    = 0,
182     EC_ENABLEONE    = ST_BLOCKNEXT,
183     EC_DISABLE      = ST_BLOCKED,
184     EC_QUERYWAITING = 2
185 }
186 
187 enum : UINT {
188     DNS_REGISTER   = 1,
189     DNS_UNREGISTER = 2,
190     DNS_FILTERON   = 4,
191     DNS_FILTEROFF  = 8
192 }
193 
194 enum : UINT {
195     HDATA_APPOWNED = 1
196 }
197 
198 enum : UINT {
199     MAX_MONITORS   = 4
200 }
201 
202 enum : int {
203     MH_CREATE  = 1,
204     MH_KEEP    = 2,
205     MH_DELETE  = 3,
206     MH_CLEANUP = 4
207 }
208 
209 extern (Windows) alias HDDEDATA
210   function(UINT, UINT, HCONV, HSZ, HSZ, HDDEDATA, ULONG_PTR, ULONG_PTR) PFNCALLBACK;
211 
212 struct HSZPAIR {
213     HSZ hszSvc;
214     HSZ hszTopic;
215 }
216 alias HSZPAIR* PHSZPAIR;
217 
218 struct CONVCONTEXT {
219     UINT                        cb = CONVCONTEXT.sizeof;
220     UINT                        wFlags;
221     UINT                        wCountryID;
222     int                         iCodePage;
223     DWORD                       dwLangID;
224     DWORD                       dwSecurity;
225     SECURITY_QUALITY_OF_SERVICE qos;
226 }
227 alias CONVCONTEXT* PCONVCONTEXT;
228 
229 struct CONVINFO {
230     DWORD       cb = CONVINFO.sizeof;
231     DWORD_PTR   hUser;
232     HCONV       hConvPartner;
233     HSZ         hszSvcPartner;
234     HSZ         hszServiceReq;
235     HSZ         hszTopic;
236     HSZ         hszItem;
237     UINT        wFmt;
238     UINT        wType;
239     UINT        wStatus;
240     UINT        wConvst;
241     UINT        wLastError;
242     HCONVLIST   hConvList;
243     CONVCONTEXT ConvCtxt;
244     HWND        hwnd;
245     HWND        hwndPartner;
246 }
247 alias CONVINFO* PCONVINFO;
248 
249 struct DDEML_MSG_HOOK_DATA {
250     UINT_PTR uiLo;
251     UINT_PTR uiHi;
252     DWORD    cbData;
253     DWORD[8] Data;
254 }
255 
256 struct MONHSZSTRUCT {
257     UINT     cb = MONHSZSTRUCT.sizeof;
258     int      fsAction;
259     DWORD    dwTime;
260     HSZ      hsz;
261     HANDLE   hTask;
262     TCHAR[1] _str = 0;
263 
264     TCHAR* str() return { return _str.ptr; }
265 }
266 alias MONHSZSTRUCT* PMONHSZSTRUCT;
267 
268 struct MONLINKSTRUCT {
269     UINT   cb = MONLINKSTRUCT.sizeof;
270     DWORD  dwTime;
271     HANDLE hTask;
272     BOOL   fEstablished;
273     BOOL   fNoData;
274     HSZ    hszSvc;
275     HSZ    hszTopic;
276     HSZ    hszItem;
277     UINT   wFmt;
278     BOOL   fServer;
279     HCONV  hConvServer;
280     HCONV  hConvClient;
281 }
282 alias MONLINKSTRUCT* PMONLINKSTRUCT;
283 
284 struct MONCONVSTRUCT {
285     UINT   cb = MONCONVSTRUCT.sizeof;
286     BOOL   fConnect;
287     DWORD  dwTime;
288     HANDLE hTask;
289     HSZ    hszSvc;
290     HSZ    hszTopic;
291     HCONV  hConvClient;
292     HCONV  hConvServer;
293 }
294 alias MONCONVSTRUCT* PMONCONVSTRUCT;
295 
296 struct MONCBSTRUCT {
297     UINT        cb = MONCBSTRUCT.sizeof;
298     DWORD       dwTime;
299     HANDLE      hTask;
300     DWORD       dwRet;
301     UINT        wType;
302     UINT        wFmt;
303     HCONV       hConv;
304     HSZ         hsz1;
305     HSZ         hsz2;
306     HDDEDATA    hData;
307     ULONG_PTR   dwData1;
308     ULONG_PTR   dwData2;
309     CONVCONTEXT cc;
310     DWORD       cbData;
311     DWORD[8]    Data;
312 }
313 alias MONCBSTRUCT* PMONCBSTRUCT;
314 
315 struct MONERRSTRUCT {
316     UINT   cb = MONERRSTRUCT.sizeof;
317     UINT   wLastError;
318     DWORD  dwTime;
319     HANDLE hTask;
320 }
321 alias MONERRSTRUCT* PMONERRSTRUCT;
322 
323 struct MONMSGSTRUCT {
324     UINT   cb = MONMSGSTRUCT.sizeof;
325     HWND   hwndTo;
326     DWORD  dwTime;
327     HANDLE hTask;
328     UINT   wMsg;
329     WPARAM wParam;
330     LPARAM lParam;
331     DDEML_MSG_HOOK_DATA dmhd;
332 }
333 alias MONMSGSTRUCT* PMONMSGSTRUCT;
334 
335 extern (Windows) {
336     BOOL DdeAbandonTransaction(DWORD, HCONV, DWORD);
337     PBYTE DdeAccessData(HDDEDATA, PDWORD);
338     HDDEDATA DdeAddData(HDDEDATA, PBYTE, DWORD, DWORD);
339     HDDEDATA DdeClientTransaction(PBYTE, DWORD, HCONV, HSZ, UINT, UINT,
340       DWORD, PDWORD);
341     int DdeCmpStringHandles(HSZ, HSZ);
342     HCONV DdeConnect(DWORD, HSZ, HSZ, PCONVCONTEXT);
343     HCONVLIST DdeConnectList(DWORD, HSZ, HSZ, HCONVLIST, PCONVCONTEXT);
344     HDDEDATA DdeCreateDataHandle(DWORD, PBYTE, DWORD, DWORD, HSZ, UINT,
345       UINT);
346     HSZ DdeCreateStringHandleA(DWORD, LPSTR, int);
347     HSZ DdeCreateStringHandleW(DWORD, LPWSTR, int);
348     BOOL DdeDisconnect(HCONV);
349     BOOL DdeDisconnectList(HCONVLIST);
350     BOOL DdeEnableCallback(DWORD, HCONV, UINT);
351     BOOL DdeFreeDataHandle(HDDEDATA);
352     BOOL DdeFreeStringHandle(DWORD, HSZ);
353     DWORD DdeGetData(HDDEDATA, PBYTE, DWORD, DWORD);
354     UINT DdeGetLastError(DWORD);
355     BOOL DdeImpersonateClient(HCONV);
356     UINT DdeInitializeA(PDWORD, PFNCALLBACK, DWORD, DWORD);
357     UINT DdeInitializeW(PDWORD, PFNCALLBACK, DWORD, DWORD);
358     BOOL DdeKeepStringHandle(DWORD, HSZ);
359     HDDEDATA DdeNameService(DWORD, HSZ, HSZ, UINT);
360     BOOL DdePostAdvise(DWORD, HSZ, HSZ);
361     UINT DdeQueryConvInfo(HCONV, DWORD, PCONVINFO);
362     HCONV DdeQueryNextServer(HCONVLIST, HCONV);
363     DWORD DdeQueryStringA(DWORD, HSZ, LPSTR, DWORD, int);
364     DWORD DdeQueryStringW(DWORD, HSZ, LPWSTR, DWORD, int);
365     HCONV DdeReconnect(HCONV);
366     BOOL DdeSetUserHandle(HCONV, DWORD, DWORD_PTR);
367     BOOL DdeUnaccessData(HDDEDATA);
368     BOOL DdeUninitialize(DWORD);
369 }
370 
371 const TCHAR[]
372     SZDDESYS_TOPIC         = "System",
373     SZDDESYS_ITEM_TOPICS   = "Topics",
374     SZDDESYS_ITEM_SYSITEMS = "SysItems",
375     SZDDESYS_ITEM_RTNMSG   = "ReturnMessage",
376     SZDDESYS_ITEM_STATUS   = "Status",
377     SZDDESYS_ITEM_FORMATS  = "Formats",
378     SZDDESYS_ITEM_HELP     = "Help",
379     SZDDE_ITEM_ITEMLIST    = "TopicItemList";
380 
381 version (Unicode) {
382     alias DdeCreateStringHandleW DdeCreateStringHandle;
383     alias DdeInitializeW DdeInitialize;
384     alias DdeQueryStringW DdeQueryString;
385 } else {
386     alias DdeCreateStringHandleA DdeCreateStringHandle;
387     alias DdeInitializeA DdeInitialize;
388     alias DdeQueryStringA DdeQueryString;
389 }