Differences From Artifact [32515530001c4a7e]:
- File
src/win32/dde.d
- 2011-02-23 12:53:16 - part of checkin [c2b7a98c21] on branch trunk - Initial import (user: kinaba) [annotate]
To Artifact [958265cdfd657f8f]:
- File
src/win32/dde.d
- 2015-04-21 10:46:55 - part of checkin [4e2933c620] on branch trunk - Rebased to the latest verson dmd 2.067. Not yet verified the outcome. (user: kinaba) [annotate]
1 +/***********************************************************************\
2 +* dde.d *
3 +* *
4 +* Windows API header module *
5 +* *
6 +* Translated from MinGW Windows headers *
7 +* by Stewart Gordon *
8 +* *
9 +* Placed into public domain *
10 +\***********************************************************************/
1 11 module win32.dde;
2 -
3 -// Translated from Microsoft Platform SDK August 2001 Edition
4 -// by Y.Tomino
5 -
6 -
7 -// #ifndef _DDEHEADER_INCLUDED_
8 -// #define _DDEHEADER_INCLUDED_
9 -
10 -// #if _MSC_VER > 1000
11 -// #pragma once
12 -// #endif
13 -
14 -// #ifndef _WINDEF_
15 -import win32.windef;
16 -// #endif
17 -
18 -// #ifdef __cplusplus
19 -// extern "C" {
20 -// #endif
21 -
22 -enum : uint { WM_DDE_FIRST = 0x03E0 }
23 -const uint WM_DDE_INITIATE = WM_DDE_FIRST;
24 -const uint WM_DDE_TERMINATE = WM_DDE_FIRST+1;
25 -const uint WM_DDE_ADVISE = WM_DDE_FIRST+2;
26 -const uint WM_DDE_UNADVISE = WM_DDE_FIRST+3;
27 -const uint WM_DDE_ACK = WM_DDE_FIRST+4;
28 -const uint WM_DDE_DATA = WM_DDE_FIRST+5;
29 -const uint WM_DDE_REQUEST = WM_DDE_FIRST+6;
30 -const uint WM_DDE_POKE = WM_DDE_FIRST+7;
31 -const uint WM_DDE_EXECUTE = WM_DDE_FIRST+8;
32 -const uint WM_DDE_LAST = WM_DDE_FIRST+8;
33 -
34 -struct _0 {
35 -// #ifndef _MAC
36 -// unsigned short bAppReturnCode:8,
37 -// reserved:6,
38 -// fBusy:1,
39 -// fAck:1;
40 -// #else
41 -// ...
42 -// #endif
12 +pragma(lib, "user32.lib");
13 +
14 +private import win32.windef;
15 +
16 +enum : uint {
17 + WM_DDE_FIRST = 0x03E0,
18 + WM_DDE_INITIATE = WM_DDE_FIRST,
19 + WM_DDE_TERMINATE,
20 + WM_DDE_ADVISE,
21 + WM_DDE_UNADVISE,
22 + WM_DDE_ACK,
23 + WM_DDE_DATA,
24 + WM_DDE_REQUEST,
25 + WM_DDE_POKE,
26 + WM_DDE_EXECUTE,
27 + WM_DDE_LAST = WM_DDE_EXECUTE
28 +}
29 +
30 +struct DDEACK {
31 + ubyte bAppReturnCode;
32 + ubyte _bf;
33 +
34 + ubyte reserved() { return cast(ubyte) (_bf & 0x3F); }
35 + bool fBusy() { return cast(bool) (_bf & 0x40); }
36 + bool fAck() { return cast(bool) (_bf & 0x80); }
37 +
38 + ubyte reserved(ubyte r) {
39 + _bf = cast(ubyte) ((_bf & ~0x3F) | (r & 0x3F));
40 + return cast(ubyte)(r & 0x3F);
41 + }
42 +
43 + bool fBusy(bool f) { _bf = cast(ubyte) ((_bf & ~0x40) | (f << 6)); return f; }
44 + bool fAck(bool f) { _bf = cast(ubyte) ((_bf & ~0x80) | (f << 7)); return f; }
45 +}
46 +
47 +struct DDEADVISE {
48 + ushort _bf;
49 + short cfFormat;
50 +
51 + ushort reserved() { return cast(ushort) (_bf & 0x3FFF); }
52 + bool fDeferUpd() { return cast(bool) (_bf & 0x4000); }
53 + bool fAckReq() { return cast(bool) (_bf & 0x8000); }
54 +
55 + ushort reserved(ushort r) {
56 + _bf = cast(ushort) ((_bf & ~0x3FFF) | (r & 0x3FFF));
57 + return cast(ushort)(r & 0x3FFF);
58 + }
59 +
60 + bool fDeferUpd(bool f) { _bf = cast(ushort) ((_bf & ~0x4000) | (f << 14)); return f; }
61 + bool fAckReq(bool f) { _bf = cast(ushort) ((_bf & ~0x8000) | (f << 15)); return f; }
62 +}
63 +
64 +struct DDEDATA {
65 + ushort _bf;
66 + short cfFormat;
67 + byte _Value;
68 +
69 + ushort unused() { return cast(ushort) (_bf & 0x0FFF); }
70 + bool fResponse() { return cast(bool) (_bf & 0x1000); }
71 + bool fRelease() { return cast(bool) (_bf & 0x2000); }
72 + bool reserved() { return cast(bool) (_bf & 0x4000); }
73 + bool fAckReq() { return cast(bool) (_bf & 0x8000); }
74 +
75 + byte* Value() { return &_Value; }
76 +
77 + ushort unused(ushort r) {
78 + _bf = cast(ushort) ((_bf & ~0x0FFF) | (r & 0x0FFF));
79 + return cast(ushort)(r & 0x0FFF);
80 + }
81 +
82 + bool fResponse(bool f) { _bf = cast(ushort) ((_bf & ~0x1000) | (f << 12)); return f; }
83 + bool fRelease(bool f) { _bf = cast(ushort) ((_bf & ~0x2000) | (f << 13)); return f; }
84 + bool reserved(bool f) { _bf = cast(ushort) ((_bf & ~0x4000) | (f << 14)); return f; }
85 + bool fAckReq(bool f) { _bf = cast(ushort) ((_bf & ~0x8000) | (f << 15)); return f; }
86 +}
87 +
88 +struct DDEPOKE {
89 + ushort _bf;
90 + short cfFormat;
91 + byte _Value;
92 +
93 + ushort unused() { return cast(ushort) (_bf & 0x1FFF); }
94 + bool fRelease() { return cast(bool) (_bf & 0x2000); }
95 + ubyte fReserved() { return cast(ubyte) ((_bf & 0xC000) >>> 14); }
96 +
97 + byte* Value() { return &_Value; }
98 +
99 + ushort unused(ushort u) {
100 + _bf = cast(ushort) ((_bf & ~0x1FFF) | (u & 0x1FFF));
101 + return cast(ushort)(u & 0x1FFF);
102 + }
103 +
104 + bool fRelease(bool f) { _bf = cast(ushort) ((_bf & ~0x2000) | (f << 13)); return f; }
105 + ubyte fReserved(ubyte r) { _bf = cast(ushort) ((_bf & ~0xC000) | (r << 14)); return r; }
106 +}
107 +
108 +deprecated struct DDELN {
109 + ushort _bf;
110 + short cfFormat;
111 +
112 + ushort unused() { return cast(ushort) (_bf & 0x1FFF); }
113 + bool fRelease() { return cast(bool) (_bf & 0x2000); }
114 + bool fDeferUpd() { return cast(bool) (_bf & 0x4000); }
115 + bool fAckReq() { return cast(bool) (_bf & 0x8000); }
116 +
117 + ushort unused(ushort u) {
118 + _bf = cast(ushort)((_bf & ~0x1FFF) | (u & 0x1FFF));
119 + return cast(ushort)(u & 0x1FFF);
120 + }
121 +
122 + bool fRelease(bool f) { _bf = cast(ushort) ((_bf & ~0x2000) | (f << 13)); return f; }
123 + bool fDeferUpd(bool f) { _bf = cast(ushort) ((_bf & ~0x4000) | (f << 14)); return f; }
124 + bool fAckReq(bool f) { _bf = cast(ushort) ((_bf & ~0x8000) | (f << 15)); return f; }
43 125 }
44 -alias _0 DDEACK;
45 -
46 -struct _1 {
47 -// #ifndef _MAC
48 -// unsigned short reserved:14,
49 -// fDeferUpd:1,
50 -// fAckReq:1;
51 -// #else
52 -// ...
53 -// #endif
54 - short cfFormat;
55 -}
56 -alias _1 DDEADVISE;
57 -
58 -struct _2 {
59 -// #ifndef _MAC
60 -// unsigned short unused:12,
61 -// fResponse:1,
62 -// fRelease:1,
63 -// reserved:1,
64 -// fAckReq:1;
65 -// #else
66 -// ...
67 -// #endif
68 - short cfFormat;
69 - BYTE Value[1];
126 +
127 +deprecated struct DDEUP {
128 + ushort _bf;
129 + short cfFormat;
130 + byte _rgb;
131 +
132 + ushort unused() { return cast(ushort) (_bf & 0x0FFF); }
133 + bool fAck() { return cast(bool) (_bf & 0x1000); }
134 + bool fRelease() { return cast(bool) (_bf & 0x2000); }
135 + bool fReserved() { return cast(bool) (_bf & 0x4000); }
136 + bool fAckReq() { return cast(bool) (_bf & 0x8000); }
137 +
138 + byte* rgb() { return &_rgb; }
139 +
140 + ushort unused(ushort r) {
141 + _bf = cast(ushort) ((_bf & ~0x0FFF) | (r & 0x0FFF));
142 + return cast(ushort)(r & 0x0FFF);
143 + }
144 +
145 + bool fAck(bool f) { _bf = cast(ushort) ((_bf & ~0x1000) | (f << 12)); return f; }
146 + bool fRelease(bool f) { _bf = cast(ushort) ((_bf & ~0x2000) | (f << 13)); return f; }
147 + bool fReserved(bool f) { _bf = cast(ushort) ((_bf & ~0x4000) | (f << 14)); return f; }
148 + bool fAckReq(bool f) { _bf = cast(ushort) ((_bf & ~0x8000) | (f << 15)); return f; }
70 149 }
71 -alias _2 DDEDATA;
72 150
73 -struct _3 {
74 -// #ifndef _MAC
75 -// unsigned short unused:13,
76 -
77 -// fRelease:1,
78 -// fReserved:2;
79 -// #else
80 -// ...
81 -// #endif
82 - short cfFormat;
83 - BYTE Value[1];
84 -
85 -}
86 -alias _3 DDEPOKE;
87 -
88 -struct _4 {
89 -// #ifndef _MAC
90 -// unsigned short unused:13,
91 -// fRelease:1,
92 -// fDeferUpd:1,
93 -// fAckReq:1;
94 -// #else
95 -// ...
96 -// #endif
97 - short cfFormat;
98 -}
99 -alias _4 DDELN;
100 -
101 -struct _5 {
102 -// #ifndef _MAC
103 -// unsigned short unused:12,
104 -// fAck:1,
105 -// fRelease:1,
106 -// fReserved:1,
107 -// fAckReq:1;
108 -// #else
109 -// ...
110 -// #endif
111 - short cfFormat;
112 - BYTE rgb[1];
151 +extern (Windows) {
152 + BOOL DdeSetQualityOfService(HWND, CPtr!(SECURITY_QUALITY_OF_SERVICE),
153 + PSECURITY_QUALITY_OF_SERVICE);
154 + BOOL ImpersonateDdeClientWindow(HWND, HWND);
155 + LPARAM PackDDElParam(UINT, UINT_PTR, UINT_PTR);
156 + BOOL UnpackDDElParam(UINT, LPARAM, PUINT_PTR, PUINT_PTR);
157 + BOOL FreeDDElParam(UINT, LPARAM);
158 + LPARAM ReuseDDElParam(LPARAM, UINT, UINT, UINT_PTR, UINT_PTR);
113 159 }
114 -alias _5 DDEUP;
160 +
161 +debug (WindowsUnitTest) {
162 + unittest {
163 + DDEACK ddeack;
164 +
165 + with (ddeack) {
166 + reserved = 10;
167 + assert (_bf == 0x0A);
168 + fBusy = true;
169 + assert (_bf == 0x4A);
170 + fAck = true;
171 + assert (_bf == 0xCA);
172 +
173 + assert (reserved == 10);
174 + assert (fBusy == true);
175 + assert (fAck == true);
176 +
177 + reserved = 43;
178 + assert (_bf == 0xEB);
179 + fBusy = false;
180 + assert (_bf == 0xAB);
181 + fAck = false;
182 + assert (_bf == 0x2B);
183 +
184 + assert (reserved == 43);
185 + assert (fBusy == false);
186 + assert (fAck == false);
187 + }
188 +
189 + DDEPOKE ddepoke;
115 190
116 -extern(Windows) export BOOL DdeSetQualityOfService(
117 - HWND hwndClient,
118 - SECURITY_QUALITY_OF_SERVICE *pqosNew,
119 - PSECURITY_QUALITY_OF_SERVICE pqosPrev);
191 + with (ddepoke) {
192 + unused = 3456;
193 + assert (_bf == 0x0D80);
194 + fRelease = true;
195 + assert (_bf == 0x2D80);
196 + fReserved = 2;
197 + assert (_bf == 0xAD80);
120 198
121 -extern(Windows) export BOOL ImpersonateDdeClientWindow(
122 - HWND hWndClient,
123 - HWND hWndServer);
199 + assert (unused == 3456);
200 + assert (fRelease == true);
201 + assert (fReserved == 2);
124 202
125 -extern(Windows) export LPARAM PackDDElParam(UINT msg, UINT_PTR uiLo, UINT_PTR uiHi);
126 -extern(Windows) export BOOL UnpackDDElParam(UINT msg, LPARAM lParam, PUINT_PTR puiLo, PUINT_PTR puiHi);
127 -extern(Windows) export BOOL FreeDDElParam(UINT msg, LPARAM lParam);
128 -extern(Windows) export LPARAM ReuseDDElParam(LPARAM lParam, UINT msgIn, UINT msgOut, UINT_PTR uiLo, UINT_PTR uiHi);
129 -
130 -// #ifdef __cplusplus
131 -// }
132 -// #endif
203 + unused = 2109;
204 + assert (_bf == 0xa83d);
205 + fRelease = false;
206 + assert (_bf == 0x883d);
207 + fReserved = 1;
208 + assert (_bf == 0x483d);
133 209
134 -// #endif // _DDEHEADER_INCLUDED_
210 + assert (unused == 2109);
211 + assert (fRelease == false);
212 + assert (fReserved == 1);
213 + }
214 + }
215 +}