2 * Unit tests for DDE functions
4 * Copyright (c) 2004 Dmitry Timoshkov
5 * Copyright (c) 2007 James Hawkins
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
33 #include "wine/test.h"
35 static const WCHAR TEST_DDE_SERVICE
[] = {'T','e','s','t','D','D','E','S','e','r','v','i','c','e',0};
37 static char exec_cmdA
[] = "ANSI dde command";
38 static WCHAR exec_cmdW
[] = {'u','n','i','c','o','d','e',' ','d','d','e',' ','c','o','m','m','a','n','d',0};
40 static WNDPROC old_dde_client_wndproc
;
42 static const DWORD default_timeout
= 200;
44 static void flush_events(void)
47 int diff
= default_timeout
;
49 DWORD time
= GetTickCount() + diff
;
53 if (MsgWaitForMultipleObjects( 0, NULL
, FALSE
, min_timeout
, QS_ALLINPUT
) == WAIT_TIMEOUT
) break;
54 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
55 diff
= time
- GetTickCount();
60 static void create_dde_window(HWND
*hwnd
, LPCSTR name
, WNDPROC wndproc
)
64 memset(&wcA
, 0, sizeof(wcA
));
65 wcA
.lpfnWndProc
= wndproc
;
66 wcA
.lpszClassName
= name
;
67 wcA
.hInstance
= GetModuleHandleA(0);
68 assert(RegisterClassA(&wcA
));
70 *hwnd
= CreateWindowExA(0, name
, NULL
, WS_POPUP
,
71 500, 500, CW_USEDEFAULT
, CW_USEDEFAULT
,
72 GetDesktopWindow(), 0, GetModuleHandleA(0), NULL
);
76 static LRESULT WINAPI
dde_server_wndproc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
79 char str
[MAX_PATH
], *ptr
;
85 static int msg_index
= 0;
86 static HWND client
= 0;
87 static BOOL executed
= FALSE
;
89 if (msg
< WM_DDE_FIRST
|| msg
> WM_DDE_LAST
)
90 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
98 client
= (HWND
)wparam
;
99 ok(msg_index
== 1, "Expected 1, got %d\n", msg_index
);
101 GlobalGetAtomNameA(LOWORD(lparam
), str
, MAX_PATH
);
102 ok(!lstrcmpA(str
, "TestDDEService"), "Expected TestDDEService, got %s\n", str
);
104 GlobalGetAtomNameA(HIWORD(lparam
), str
, MAX_PATH
);
105 ok(!lstrcmpA(str
, "TestDDETopic"), "Expected TestDDETopic, got %s\n", str
);
107 SendMessageA(client
, WM_DDE_ACK
, (WPARAM
)hwnd
, lparam
);
114 ok((msg_index
>= 2 && msg_index
<= 4) ||
115 (msg_index
>= 7 && msg_index
<= 8),
116 "Expected 2, 3, 4, 7 or 8, got %d\n", msg_index
);
117 ok(wparam
== (WPARAM
)client
, "Expected client hwnd, got %08lx\n", wparam
);
118 ok(LOWORD(lparam
) == CF_TEXT
, "Expected CF_TEXT, got %d\n", LOWORD(lparam
));
120 GlobalGetAtomNameA(HIWORD(lparam
), str
, MAX_PATH
);
122 ok(!lstrcmpA(str
, "request"), "Expected request, got %s\n", str
);
124 ok(!lstrcmpA(str
, "executed"), "Expected executed, got %s\n", str
);
129 lstrcpyA(str
, "command executed\r\n");
131 lstrcpyA(str
, "command not executed\r\n");
134 lstrcpyA(str
, "requested data\r\n");
136 size
= sizeof(DDEDATA
) + lstrlenA(str
) + 1;
137 hglobal
= GlobalAlloc(GMEM_MOVEABLE
, size
);
138 ok(hglobal
!= NULL
, "Expected non-NULL hglobal\n");
140 data
= GlobalLock(hglobal
);
141 ZeroMemory(data
, size
);
143 /* setting fResponse to FALSE at this point destroys
144 * the internal messaging state of native dde
146 data
->fResponse
= TRUE
;
149 data
->fRelease
= TRUE
;
150 else if (msg_index
== 3)
151 data
->fAckReq
= TRUE
;
153 data
->cfFormat
= CF_TEXT
;
154 lstrcpyA((LPSTR
)data
->Value
, str
);
155 GlobalUnlock(hglobal
);
157 lparam
= PackDDElParam(WM_DDE_ACK
, (UINT
)hglobal
, HIWORD(lparam
));
158 PostMessageA(client
, WM_DDE_DATA
, (WPARAM
)hwnd
, lparam
);
165 ok(msg_index
== 5 || msg_index
== 6, "Expected 5 or 6, got %d\n", msg_index
);
166 ok(wparam
== (WPARAM
)client
, "Expected client hwnd, got %08lx\n", wparam
);
168 UnpackDDElParam(WM_DDE_POKE
, lparam
, &lo
, &hi
);
170 GlobalGetAtomNameA(hi
, str
, MAX_PATH
);
171 ok(!lstrcmpA(str
, "poker"), "Expected poker, got %s\n", str
);
173 poke
= GlobalLock((HGLOBAL
)lo
);
174 ok(poke
!= NULL
, "Expected non-NULL poke\n");
175 ok(poke
->fReserved
== 0, "Expected 0, got %d\n", poke
->fReserved
);
176 ok(poke
->unused
== 0, "Expected 0, got %d\n", poke
->unused
);
177 ok(poke
->fRelease
== TRUE
, "Expected TRUE, got %d\n", poke
->fRelease
);
178 ok(poke
->cfFormat
== CF_TEXT
, "Expected CF_TEXT, got %d\n", poke
->cfFormat
);
182 size
= GlobalSize((HGLOBAL
)lo
);
183 ok(size
== 4, "got %d\n", size
);
186 ok(!lstrcmpA((LPSTR
)poke
->Value
, "poke data\r\n"),
187 "Expected 'poke data\\r\\n', got %s\n", poke
->Value
);
189 GlobalUnlock((HGLOBAL
)lo
);
191 lparam
= PackDDElParam(WM_DDE_ACK
, DDE_FACK
, hi
);
192 PostMessageA(client
, WM_DDE_ACK
, (WPARAM
)hwnd
, lparam
);
199 ok(msg_index
== 7, "Expected 7, got %d\n", msg_index
);
200 ok(wparam
== (WPARAM
)client
, "Expected client hwnd, got %08lx\n", wparam
);
202 ptr
= GlobalLock((HGLOBAL
)lparam
);
203 ok(!lstrcmpA(ptr
, "[Command(Var)]"), "Expected [Command(Var)], got %s\n", ptr
);
204 GlobalUnlock((HGLOBAL
)lparam
);
208 lparam
= ReuseDDElParam(lparam
, WM_DDE_EXECUTE
, WM_DDE_ACK
, DDE_FACK
, HIWORD(lparam
));
209 PostMessageA(client
, WM_DDE_ACK
, (WPARAM
)hwnd
, lparam
);
214 case WM_DDE_TERMINATE
:
216 ok(msg_index
== 9, "Expected 9, got %d\n", msg_index
);
217 ok(wparam
== (WPARAM
)client
, "Expected client hwnd, got %08lx\n", wparam
);
218 ok(lparam
== 0, "Expected 0, got %08lx\n", lparam
);
220 PostMessageA(client
, WM_DDE_TERMINATE
, (WPARAM
)hwnd
, 0);
226 ok(FALSE
, "Unhandled msg: %08x\n", msg
);
229 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
232 static void test_msg_server(HANDLE hproc
, HANDLE hthread
)
238 create_dde_window(&hwnd
, "dde_server", dde_server_wndproc
);
239 ResumeThread( hthread
);
241 while (MsgWaitForMultipleObjects( 1, &hproc
, FALSE
, INFINITE
, QS_ALLINPUT
) != 0)
243 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
247 GetExitCodeProcess( hproc
, &res
);
248 ok( !res
, "client failed with %u error(s)\n", res
);
251 static HDDEDATA CALLBACK
client_ddeml_callback(UINT uType
, UINT uFmt
, HCONV hconv
,
252 HSZ hsz1
, HSZ hsz2
, HDDEDATA hdata
,
253 ULONG_PTR dwData1
, ULONG_PTR dwData2
)
255 ok(FALSE
, "Unhandled msg: %08x\n", uType
);
259 static void test_ddeml_client(void)
266 HSZ server
, topic
, item
;
271 ret
= DdeInitializeA(&client_pid
, client_ddeml_callback
, APPCMD_CLIENTONLY
, 0);
272 ok(ret
== DMLERR_NO_ERROR
, "Expected DMLERR_NO_ERROR, got %d\n", ret
);
274 /* FIXME: make these atoms global and check them in the server */
276 server
= DdeCreateStringHandleA(client_pid
, "TestDDEService", CP_WINANSI
);
277 topic
= DdeCreateStringHandleA(client_pid
, "TestDDETopic", CP_WINANSI
);
279 DdeGetLastError(client_pid
);
280 conversation
= DdeConnect(client_pid
, server
, topic
, NULL
);
281 ok(conversation
!= NULL
, "Expected non-NULL conversation\n");
282 ret
= DdeGetLastError(client_pid
);
283 ok(ret
== DMLERR_NO_ERROR
, "Expected DMLERR_NO_ERROR, got %d\n", ret
);
285 DdeFreeStringHandle(client_pid
, server
);
287 item
= DdeCreateStringHandleA(client_pid
, "request", CP_WINANSI
);
289 /* XTYP_REQUEST, fRelease = TRUE */
291 DdeGetLastError(client_pid
);
292 hdata
= DdeClientTransaction(NULL
, 0, conversation
, item
, CF_TEXT
, XTYP_REQUEST
, default_timeout
, &res
);
293 ret
= DdeGetLastError(client_pid
);
294 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
297 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %08x\n", res
);
300 ok(FALSE
, "hdata is NULL\n");
303 str
= (LPSTR
)DdeAccessData(hdata
, &size
);
304 ok(!lstrcmpA(str
, "requested data\r\n"), "Expected 'requested data\\r\\n', got %s\n", str
);
305 ok(size
== 19, "Expected 19, got %d\n", size
);
307 ret
= DdeUnaccessData(hdata
);
308 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
311 /* XTYP_REQUEST, fAckReq = TRUE */
313 DdeGetLastError(client_pid
);
314 hdata
= DdeClientTransaction(NULL
, 0, conversation
, item
, CF_TEXT
, XTYP_REQUEST
, default_timeout
, &res
);
315 ret
= DdeGetLastError(client_pid
);
318 ok(res
== DDE_FNOTPROCESSED
, "Expected DDE_FNOTPROCESSED, got %d\n", res
);
319 ok(ret
== DMLERR_MEMORY_ERROR
, "Expected DMLERR_MEMORY_ERROR, got %d\n", ret
);
322 ok(FALSE
, "hdata is NULL\n");
325 str
= (LPSTR
)DdeAccessData(hdata
, &size
);
326 ok(!lstrcmpA(str
, "requested data\r\n"), "Expected 'requested data\\r\\n', got %s\n", str
);
327 ok(size
== 19, "Expected 19, got %d\n", size
);
329 ret
= DdeUnaccessData(hdata
);
330 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
333 /* XTYP_REQUEST, all params normal */
335 DdeGetLastError(client_pid
);
336 hdata
= DdeClientTransaction(NULL
, 0, conversation
, item
, CF_TEXT
, XTYP_REQUEST
, default_timeout
, &res
);
337 ret
= DdeGetLastError(client_pid
);
338 ok(ret
== DMLERR_NO_ERROR
, "Expected DMLERR_NO_ERROR, got %d\n", ret
);
341 ok(res
== DDE_FNOTPROCESSED
, "Expected DDE_FNOTPROCESSED, got %d\n", res
);
344 ok(FALSE
, "hdata is NULL\n");
347 str
= (LPSTR
)DdeAccessData(hdata
, &size
);
348 ok(!lstrcmpA(str
, "requested data\r\n"), "Expected 'requested data\\r\\n', got %s\n", str
);
349 ok(size
== 19, "Expected 19, got %d\n", size
);
351 ret
= DdeUnaccessData(hdata
);
352 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
355 /* XTYP_REQUEST, no item */
357 DdeGetLastError(client_pid
);
358 hdata
= DdeClientTransaction(NULL
, 0, conversation
, 0, CF_TEXT
, XTYP_REQUEST
, default_timeout
, &res
);
359 ret
= DdeGetLastError(client_pid
);
360 ok(hdata
== NULL
, "Expected NULL hdata, got %p\n", hdata
);
361 ok(res
== 0xdeadbeef, "Expected 0xdeadbeef, got %08x\n", res
);
362 ok(ret
== DMLERR_INVALIDPARAMETER
, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret
);
364 DdeFreeStringHandle(client_pid
, item
);
366 item
= DdeCreateStringHandleA(client_pid
, "poker", CP_WINANSI
);
368 lstrcpyA(buffer
, "poke data\r\n");
369 hdata
= DdeCreateDataHandle(client_pid
, (LPBYTE
)buffer
, lstrlenA(buffer
) + 1,
370 0, item
, CF_TEXT
, 0);
371 ok(hdata
!= NULL
, "Expected non-NULL hdata\n");
373 /* XTYP_POKE, no item */
375 DdeGetLastError(client_pid
);
376 op
= DdeClientTransaction((LPBYTE
)hdata
, -1, conversation
, 0, CF_TEXT
, XTYP_POKE
, default_timeout
, &res
);
377 ret
= DdeGetLastError(client_pid
);
378 ok(op
== NULL
, "Expected NULL, got %p\n", op
);
379 ok(res
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res
);
380 ok(ret
== DMLERR_INVALIDPARAMETER
, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret
);
382 /* XTYP_POKE, no data */
384 DdeGetLastError(client_pid
);
385 op
= DdeClientTransaction(NULL
, 0, conversation
, 0, CF_TEXT
, XTYP_POKE
, default_timeout
, &res
);
386 ret
= DdeGetLastError(client_pid
);
387 ok(op
== NULL
, "Expected NULL, got %p\n", op
);
388 ok(res
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res
);
389 ok(ret
== DMLERR_INVALIDPARAMETER
, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret
);
391 /* XTYP_POKE, wrong size */
393 DdeGetLastError(client_pid
);
394 op
= DdeClientTransaction((LPBYTE
)hdata
, 0, conversation
, item
, CF_TEXT
, XTYP_POKE
, default_timeout
, &res
);
395 ret
= DdeGetLastError(client_pid
);
396 ok(op
== (HDDEDATA
)TRUE
, "Expected TRUE, got %p\n", op
);
397 ok(res
== DDE_FACK
, "Expected DDE_FACK, got %d\n", res
);
398 ok(ret
== DMLERR_NO_ERROR
, "Expected DMLERR_NO_ERROR, got %d\n", ret
);
400 /* XTYP_POKE, correct params */
402 DdeGetLastError(client_pid
);
403 op
= DdeClientTransaction((LPBYTE
)hdata
, -1, conversation
, item
, CF_TEXT
, XTYP_POKE
, default_timeout
, &res
);
404 ret
= DdeGetLastError(client_pid
);
405 ok(op
== (HDDEDATA
)TRUE
, "Expected TRUE, got %p\n", op
);
406 ok(res
== DDE_FACK
, "Expected DDE_FACK, got %d\n", res
);
407 ok(ret
== DMLERR_NO_ERROR
, "Expected DMLERR_NO_ERROR, got %d\n", ret
);
409 DdeFreeDataHandle(hdata
);
411 lstrcpyA(buffer
, "[Command(Var)]");
412 hdata
= DdeCreateDataHandle(client_pid
, (LPBYTE
)buffer
, lstrlenA(buffer
) + 1,
413 0, NULL
, CF_TEXT
, 0);
414 ok(hdata
!= NULL
, "Expected non-NULL hdata\n");
416 /* XTYP_EXECUTE, correct params */
418 DdeGetLastError(client_pid
);
419 op
= DdeClientTransaction((LPBYTE
)hdata
, -1, conversation
, NULL
, 0, XTYP_EXECUTE
, default_timeout
, &res
);
420 ret
= DdeGetLastError(client_pid
);
421 ok(ret
== DMLERR_NO_ERROR
, "Expected DMLERR_NO_ERROR, got %d\n", ret
);
422 ok(op
== (HDDEDATA
)TRUE
, "Expected TRUE, got %p\n", op
);
423 ok(res
== DDE_FACK
, "Expected DDE_FACK, got %d\n", res
);
425 /* XTYP_EXECUTE, no data */
427 DdeGetLastError(client_pid
);
428 op
= DdeClientTransaction(NULL
, 0, conversation
, NULL
, 0, XTYP_EXECUTE
, default_timeout
, &res
);
429 ret
= DdeGetLastError(client_pid
);
430 ok(op
== NULL
, "Expected NULL, got %p\n", op
);
431 ok(res
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res
);
434 ok(ret
== DMLERR_MEMORY_ERROR
, "Expected DMLERR_MEMORY_ERROR, got %d\n", ret
);
437 /* XTYP_EXECUTE, no data, -1 size */
439 DdeGetLastError(client_pid
);
440 op
= DdeClientTransaction(NULL
, -1, conversation
, NULL
, 0, XTYP_EXECUTE
, default_timeout
, &res
);
441 ret
= DdeGetLastError(client_pid
);
442 ok(op
== NULL
, "Expected NULL, got %p\n", op
);
443 ok(res
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res
);
446 ok(ret
== DMLERR_INVALIDPARAMETER
, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret
);
449 DdeFreeStringHandle(client_pid
, topic
);
450 DdeFreeDataHandle(hdata
);
452 item
= DdeCreateStringHandleA(client_pid
, "executed", CP_WINANSI
);
454 /* verify the execute */
456 DdeGetLastError(client_pid
);
457 hdata
= DdeClientTransaction(NULL
, 0, conversation
, item
, CF_TEXT
, XTYP_REQUEST
, default_timeout
, &res
);
458 ret
= DdeGetLastError(client_pid
);
459 ok(ret
== DMLERR_NO_ERROR
, "Expected DMLERR_NO_ERROR, got %d\n", ret
);
462 ok(res
== DDE_FNOTPROCESSED
, "Expected DDE_FNOTPROCESSED, got %d\n", res
);
465 ok(FALSE
, "hdata is NULL\n");
468 str
= (LPSTR
)DdeAccessData(hdata
, &size
);
469 ok(!lstrcmpA(str
, "command executed\r\n"), "Expected 'command executed\\r\\n', got %s\n", str
);
470 ok(size
== 21, "Expected 21, got %d\n", size
);
472 ret
= DdeUnaccessData(hdata
);
473 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
476 /* invalid transactions */
478 DdeGetLastError(client_pid
);
479 op
= DdeClientTransaction(NULL
, 0, conversation
, item
, CF_TEXT
, XTYP_ADVREQ
, default_timeout
, &res
);
480 ret
= DdeGetLastError(client_pid
);
481 ok(op
== NULL
, "Expected NULL, got %p\n", op
);
482 ok(res
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res
);
483 ok(ret
== DMLERR_INVALIDPARAMETER
, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret
);
486 DdeGetLastError(client_pid
);
487 op
= DdeClientTransaction(NULL
, 0, conversation
, item
, CF_TEXT
, XTYP_CONNECT
, default_timeout
, &res
);
488 ret
= DdeGetLastError(client_pid
);
489 ok(op
== NULL
, "Expected NULL, got %p\n", op
);
490 ok(res
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res
);
491 ok(ret
== DMLERR_INVALIDPARAMETER
, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret
);
494 DdeGetLastError(client_pid
);
495 op
= DdeClientTransaction(NULL
, 0, conversation
, item
, CF_TEXT
, XTYP_CONNECT_CONFIRM
, default_timeout
, &res
);
496 ret
= DdeGetLastError(client_pid
);
497 ok(op
== NULL
, "Expected NULL, got %p\n", op
);
498 ok(res
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res
);
499 ok(ret
== DMLERR_INVALIDPARAMETER
, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret
);
502 DdeGetLastError(client_pid
);
503 op
= DdeClientTransaction(NULL
, 0, conversation
, item
, CF_TEXT
, XTYP_DISCONNECT
, default_timeout
, &res
);
504 ret
= DdeGetLastError(client_pid
);
505 ok(op
== NULL
, "Expected NULL, got %p\n", op
);
506 ok(res
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res
);
507 ok(ret
== DMLERR_INVALIDPARAMETER
, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret
);
510 DdeGetLastError(client_pid
);
511 op
= DdeClientTransaction(NULL
, 0, conversation
, item
, CF_TEXT
, XTYP_ERROR
, default_timeout
, &res
);
512 ret
= DdeGetLastError(client_pid
);
513 ok(op
== NULL
, "Expected NULL, got %p\n", op
);
514 ok(res
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res
);
515 ok(ret
== DMLERR_INVALIDPARAMETER
, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret
);
518 DdeGetLastError(client_pid
);
519 op
= DdeClientTransaction(NULL
, 0, conversation
, item
, CF_TEXT
, XTYP_MONITOR
, default_timeout
, &res
);
520 ret
= DdeGetLastError(client_pid
);
521 ok(op
== NULL
, "Expected NULL, got %p\n", op
);
522 ok(res
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res
);
523 ok(ret
== DMLERR_INVALIDPARAMETER
, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret
);
526 DdeGetLastError(client_pid
);
527 op
= DdeClientTransaction(NULL
, 0, conversation
, item
, CF_TEXT
, XTYP_REGISTER
, default_timeout
, &res
);
528 ret
= DdeGetLastError(client_pid
);
529 ok(op
== NULL
, "Expected NULL, got %p\n", op
);
530 ok(res
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res
);
531 ok(ret
== DMLERR_INVALIDPARAMETER
, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret
);
534 DdeGetLastError(client_pid
);
535 op
= DdeClientTransaction(NULL
, 0, conversation
, item
, CF_TEXT
, XTYP_UNREGISTER
, default_timeout
, &res
);
536 ret
= DdeGetLastError(client_pid
);
537 ok(op
== NULL
, "Expected NULL, got %p\n", op
);
538 ok(res
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res
);
539 ok(ret
== DMLERR_INVALIDPARAMETER
, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret
);
542 DdeGetLastError(client_pid
);
543 op
= DdeClientTransaction(NULL
, 0, conversation
, item
, CF_TEXT
, XTYP_WILDCONNECT
, default_timeout
, &res
);
544 ret
= DdeGetLastError(client_pid
);
545 ok(op
== NULL
, "Expected NULL, got %p\n", op
);
546 ok(res
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res
);
547 ok(ret
== DMLERR_INVALIDPARAMETER
, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret
);
550 DdeGetLastError(client_pid
);
551 op
= DdeClientTransaction(NULL
, 0, conversation
, item
, CF_TEXT
, XTYP_XACT_COMPLETE
, default_timeout
, &res
);
552 ret
= DdeGetLastError(client_pid
);
553 ok(op
== NULL
, "Expected NULL, got %p\n", op
);
554 ok(res
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res
);
555 ok(ret
== DMLERR_INVALIDPARAMETER
, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret
);
557 DdeFreeStringHandle(client_pid
, item
);
559 ret
= DdeDisconnect(conversation
);
560 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
562 ret
= DdeUninitialize(client_pid
);
563 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
566 static DWORD server_pid
;
568 static HDDEDATA CALLBACK
server_ddeml_callback(UINT uType
, UINT uFmt
, HCONV hconv
,
569 HSZ hsz1
, HSZ hsz2
, HDDEDATA hdata
,
570 ULONG_PTR dwData1
, ULONG_PTR dwData2
)
572 char str
[MAX_PATH
], *ptr
;
576 static int msg_index
= 0;
577 static HCONV conversation
= 0;
585 ok(msg_index
== 1, "Expected 1, got %d\n", msg_index
);
586 ok(uFmt
== 0, "Expected 0, got %d\n", uFmt
);
587 ok(hconv
== 0, "Expected 0, got %p\n", hconv
);
588 ok(hdata
== 0, "Expected 0, got %p\n", hdata
);
589 ok(dwData1
== 0, "Expected 0, got %08lx\n", dwData1
);
590 ok(dwData2
== 0, "Expected 0, got %08lx\n", dwData2
);
592 size
= DdeQueryStringA(server_pid
, hsz1
, str
, MAX_PATH
, CP_WINANSI
);
593 ok(!lstrcmpA(str
, "TestDDEServer"), "Expected TestDDEServer, got %s\n", str
);
594 ok(size
== 13, "Expected 13, got %d\n", size
);
596 size
= DdeQueryStringA(server_pid
, hsz2
, str
, MAX_PATH
, CP_WINANSI
);
597 ok(!strncmp(str
, "TestDDEServer(", 14), "Expected TestDDEServer(, got %s\n", str
);
598 ok(str
[size
- 1] == ')', "Expected ')', got %c\n", str
[size
- 1]);
599 ok(size
== 25, "Expected 25, got %d\n", size
);
601 return (HDDEDATA
)TRUE
;
606 ok(msg_index
== 2, "Expected 2, got %d\n", msg_index
);
607 ok(uFmt
== 0, "Expected 0, got %d\n", uFmt
);
608 ok(hconv
== 0, "Expected 0, got %p\n", hconv
);
609 ok(hdata
== 0, "Expected 0, got %p\n", hdata
);
610 ok(dwData1
== 0, "Expected 0, got %08lx\n", dwData1
);
611 ok(dwData2
== FALSE
, "Expected FALSE, got %08lx\n", dwData2
);
613 size
= DdeQueryStringA(server_pid
, hsz1
, str
, MAX_PATH
, CP_WINANSI
);
614 ok(!lstrcmpA(str
, "TestDDETopic"), "Expected TestDDETopic, got %s\n", str
);
615 ok(size
== 12, "Expected 12, got %d\n", size
);
617 size
= DdeQueryStringA(server_pid
, hsz2
, str
, MAX_PATH
, CP_WINANSI
);
618 ok(!lstrcmpA(str
, "TestDDEServer"), "Expected TestDDEServer, got %s\n", str
);
619 ok(size
== 13, "Expected 13, got %d\n", size
);
621 return (HDDEDATA
)TRUE
;
624 case XTYP_CONNECT_CONFIRM
:
626 conversation
= hconv
;
628 ok(msg_index
== 3, "Expected 3, got %d\n", msg_index
);
629 ok(uFmt
== 0, "Expected 0, got %d\n", uFmt
);
630 ok(hconv
!= NULL
, "Expected non-NULL hconv\n");
631 ok(hdata
== 0, "Expected 0, got %p\n", hdata
);
632 ok(dwData1
== 0, "Expected 0, got %08lx\n", dwData1
);
633 ok(dwData2
== FALSE
, "Expected FALSE, got %08lx\n", dwData2
);
635 size
= DdeQueryStringA(server_pid
, hsz1
, str
, MAX_PATH
, CP_WINANSI
);
636 ok(!lstrcmpA(str
, "TestDDETopic"), "Expected TestDDETopic, got %s\n", str
);
637 ok(size
== 12, "Expected 12, got %d\n", size
);
639 size
= DdeQueryStringA(server_pid
, hsz2
, str
, MAX_PATH
, CP_WINANSI
);
640 ok(!lstrcmpA(str
, "TestDDEServer"), "Expected TestDDEServer, got %s\n", str
);
641 ok(size
== 13, "Expected 13, got %d\n", size
);
643 return (HDDEDATA
)TRUE
;
648 ok(msg_index
== 4 || msg_index
== 5 || msg_index
== 6,
649 "Expected 4, 5 or 6, got %d\n", msg_index
);
650 ok(hconv
== conversation
, "Expected conversation handle, got %p\n", hconv
);
651 ok(hdata
== 0, "Expected 0, got %p\n", hdata
);
652 ok(dwData1
== 0, "Expected 0, got %08lx\n", dwData1
);
653 ok(dwData2
== 0, "Expected 0, got %08lx\n", dwData2
);
656 ok(uFmt
== 0xbeef, "Expected 0xbeef, got %08x\n", uFmt
);
658 ok(uFmt
== CF_TEXT
, "Expected CF_TEXT, got %08x\n", uFmt
);
660 size
= DdeQueryStringA(server_pid
, hsz1
, str
, MAX_PATH
, CP_WINANSI
);
661 ok(!lstrcmpA(str
, "TestDDETopic"), "Expected TestDDETopic, got %s\n", str
);
662 ok(size
== 12, "Expected 12, got %d\n", size
);
664 size
= DdeQueryStringA(server_pid
, hsz2
, str
, MAX_PATH
, CP_WINANSI
);
670 ok(!lstrcmpA(str
, ""), "Expected empty string, got %s\n", str
);
671 ok(size
== 1, "Expected 1, got %d\n", size
);
674 else if (msg_index
== 6)
676 ok(!lstrcmpA(str
, "request"), "Expected request, got %s\n", str
);
677 ok(size
== 7, "Expected 7, got %d\n", size
);
682 lstrcpyA(str
, "requested data\r\n");
683 return DdeCreateDataHandle(server_pid
, (LPBYTE
)str
, lstrlenA(str
) + 1,
684 0, hsz2
, CF_TEXT
, 0);
692 ok(msg_index
== 7 || msg_index
== 8, "Expected 7 or 8, got %d\n", msg_index
);
693 ok(uFmt
== CF_TEXT
, "Expected CF_TEXT, got %d\n", uFmt
);
694 ok(hconv
== conversation
, "Expected conversation handle, got %p\n", hconv
);
695 ok(dwData1
== 0, "Expected 0, got %08lx\n", dwData1
);
696 ok(dwData2
== 0, "Expected 0, got %08lx\n", dwData2
);
698 size
= DdeQueryStringA(server_pid
, hsz1
, str
, MAX_PATH
, CP_WINANSI
);
699 ok(!lstrcmpA(str
, "TestDDETopic"), "Expected TestDDETopic, got %s\n", str
);
700 ok(size
== 12, "Expected 12, got %d\n", size
);
702 ptr
= (LPSTR
)DdeAccessData(hdata
, &size
);
703 ok(!lstrcmpA(ptr
, "poke data\r\n"), "Expected 'poke data\\r\\n', got %s\n", ptr
);
704 ok(size
== 12, "Expected 12, got %d\n", size
);
705 DdeUnaccessData(hdata
);
707 size
= DdeQueryStringA(server_pid
, hsz2
, str
, MAX_PATH
, CP_WINANSI
);
712 ok(!lstrcmpA(str
, ""), "Expected empty string, got %s\n", str
);
713 ok(size
== 1, "Expected 1, got %d\n", size
);
718 ok(!lstrcmpA(str
, "poke"), "Expected poke, got %s\n", str
);
719 ok(size
== 4, "Expected 4, got %d\n", size
);
722 return (HDDEDATA
)DDE_FACK
;
727 ok(msg_index
== 9 || msg_index
== 10, "Expected 9 or 10, got %d\n", msg_index
);
728 ok(uFmt
== 0, "Expected 0, got %d\n", uFmt
);
729 ok(hconv
== conversation
, "Expected conversation handle, got %p\n", hconv
);
730 ok(dwData1
== 0, "Expected 0, got %08lx\n", dwData1
);
731 ok(dwData2
== 0, "Expected 0, got %08lx\n", dwData2
);
732 ok(hsz2
== 0, "Expected 0, got %p\n", hsz2
);
734 size
= DdeQueryStringA(server_pid
, hsz1
, str
, MAX_PATH
, CP_WINANSI
);
735 ok(!lstrcmpA(str
, "TestDDETopic"), "Expected TestDDETopic, got %s\n", str
);
736 ok(size
== 12, "Expected 12, got %d\n", size
);
738 ptr
= (LPSTR
)DdeAccessData(hdata
, &size
);
742 ok(!lstrcmpA(ptr
, "[Command(Var)]"), "Expected '[Command(Var)]', got %s\n", ptr
);
743 ok(size
== 15, "Expected 15, got %d\n", size
);
744 ret
= (HDDEDATA
)DDE_FACK
;
748 ok(!lstrcmpA(ptr
, "[BadCommand(Var)]"), "Expected '[BadCommand(Var)]', got %s\n", ptr
);
749 ok(size
== 18, "Expected 18, got %d\n", size
);
750 ret
= (HDDEDATA
)DDE_FNOTPROCESSED
;
753 DdeUnaccessData(hdata
);
758 case XTYP_DISCONNECT
:
760 ok(msg_index
== 11, "Expected 11, got %d\n", msg_index
);
761 ok(uFmt
== 0, "Expected 0, got %d\n", uFmt
);
762 ok(hconv
== conversation
, "Expected conversation handle, got %p\n", hconv
);
763 ok(dwData1
== 0, "Expected 0, got %08lx\n", dwData1
);
764 ok(dwData2
== 0, "Expected 0, got %08lx\n", dwData2
);
765 ok(hsz1
== 0, "Expected 0, got %p\n", hsz2
);
766 ok(hsz2
== 0, "Expected 0, got %p\n", hsz2
);
772 ok(FALSE
, "Unhandled msg: %08x\n", uType
);
778 static void test_ddeml_server(HANDLE hproc
)
786 /* set up DDE server */
788 res
= DdeInitialize(&server_pid
, server_ddeml_callback
, APPCLASS_STANDARD
, 0);
789 ok(res
== DMLERR_NO_ERROR
, "Expected DMLERR_NO_ERROR, got %d\n", res
);
791 server
= DdeCreateStringHandle(server_pid
, "TestDDEServer", CP_WINANSI
);
792 ok(server
!= NULL
, "Expected non-NULL string handle\n");
794 hdata
= DdeNameService(server_pid
, server
, 0, DNS_REGISTER
);
795 ok(hdata
== (HDDEDATA
)TRUE
, "Expected TRUE, got %p\n", hdata
);
797 while (MsgWaitForMultipleObjects( 1, &hproc
, FALSE
, INFINITE
, QS_ALLINPUT
) != 0)
799 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
801 ret
= DdeUninitialize(server_pid
);
802 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
803 GetExitCodeProcess( hproc
, &res
);
804 ok( !res
, "client failed with %u error(s)\n", res
);
807 static HWND client_hwnd
, server_hwnd
;
808 static ATOM server
, topic
, item
;
809 static HGLOBAL execute_hglobal
;
811 static LRESULT WINAPI
dde_msg_client_wndproc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
820 static int msg_index
= 0;
822 if (msg
< WM_DDE_FIRST
|| msg
> WM_DDE_LAST
)
823 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
829 case WM_DDE_INITIATE
:
831 ok(msg_index
== 1, "Expected 1, got %d\n", msg_index
);
832 ok(wparam
== (WPARAM
)client_hwnd
, "Expected client hwnd, got %08lx\n", wparam
);
834 size
= GlobalGetAtomNameA(LOWORD(lparam
), str
, MAX_PATH
);
835 ok(LOWORD(lparam
) == server
, "Expected server atom, got %08x\n", LOWORD(lparam
));
836 ok(!lstrcmpA(str
, "TestDDEServer"), "Expected TestDDEServer, got %s\n", str
);
837 ok(size
== 13, "Expected 13, got %d\n", size
);
839 size
= GlobalGetAtomNameA(HIWORD(lparam
), str
, MAX_PATH
);
840 ok(HIWORD(lparam
) == topic
, "Expected topic atom, got %08x\n", HIWORD(lparam
));
841 ok(!lstrcmpA(str
, "TestDDETopic"), "Expected TestDDETopic, got %s\n", str
);
842 ok(size
== 12, "Expected 12, got %d\n", size
);
849 ok((msg_index
>= 2 && msg_index
<= 4) || (msg_index
>= 6 && msg_index
<= 10),
850 "Expected 2, 3, 4, 6, 7, 8, 9 or 10, got %d\n", msg_index
);
854 server_hwnd
= (HWND
)wparam
;
855 ok(wparam
!= 0, "Expected non-NULL wparam, got %08lx\n", wparam
);
857 size
= GlobalGetAtomNameA(LOWORD(lparam
), str
, MAX_PATH
);
858 ok(LOWORD(lparam
) == server
, "Expected server atom, got %08x\n", LOWORD(lparam
));
859 ok(!lstrcmpA(str
, "TestDDEServer"), "Expected TestDDEServer, got %s\n", str
);
860 ok(size
== 13, "Expected 13, got %d\n", size
);
862 size
= GlobalGetAtomNameA(HIWORD(lparam
), str
, MAX_PATH
);
863 ok(HIWORD(lparam
) == topic
, "Expected topic atom, got %08x\n", HIWORD(lparam
));
864 ok(!lstrcmpA(str
, "TestDDETopic"), "Expected TestDDETopic, got %s\n", str
);
865 ok(size
== 12, "Expected 12, got %d\n", size
);
867 else if (msg_index
== 9 || msg_index
== 10)
869 ok(wparam
== (WPARAM
)server_hwnd
, "Expected server hwnd, got %08lx\n", wparam
);
871 UnpackDDElParam(WM_DDE_ACK
, lparam
, &lo
, &hi
);
874 ok(ack
->bAppReturnCode
== 0, "Expected 0, got %d\n", ack
->bAppReturnCode
);
875 ok(ack
->reserved
== 0, "Expected 0, got %d\n", ack
->reserved
);
876 ok(ack
->fBusy
== FALSE
, "Expected FALSE, got %d\n", ack
->fBusy
);
878 ok(hi
== (UINT_PTR
)execute_hglobal
, "Execpted execute hglobal, got %08lx\n", hi
);
879 ptr
= GlobalLock((HGLOBAL
)hi
);
883 ok(ack
->fAck
== TRUE
, "Expected TRUE, got %d\n", ack
->fAck
);
884 ok(!lstrcmpA(ptr
, "[Command(Var)]"), "Expected '[Command(Var)]', got %s\n", ptr
);
888 ok(ack
->fAck
== FALSE
, "Expected FALSE, got %d\n", ack
->fAck
);
889 ok(!lstrcmpA(ptr
, "[BadCommand(Var)]"), "Expected '[BadCommand(Var)]', got %s\n", ptr
);
892 GlobalUnlock((HGLOBAL
)hi
);
896 ok(wparam
== (WPARAM
)server_hwnd
, "Expected server hwnd, got %08lx\n", wparam
);
898 UnpackDDElParam(WM_DDE_ACK
, lparam
, &lo
, &hi
);
901 ok(ack
->bAppReturnCode
== 0, "Expected 0, got %d\n", ack
->bAppReturnCode
);
902 ok(ack
->reserved
== 0, "Expected 0, got %d\n", ack
->reserved
);
903 ok(ack
->fBusy
== FALSE
, "Expected FALSE, got %d\n", ack
->fBusy
);
906 ok(ack
->fAck
== TRUE
, "Expected TRUE, got %d\n", ack
->fAck
);
909 if (msg_index
== 6) todo_wine
910 ok(ack
->fAck
== FALSE
, "Expected FALSE, got %d\n", ack
->fAck
);
913 size
= GlobalGetAtomNameA(hi
, str
, MAX_PATH
);
916 ok(hi
== item
, "Expected item atom, got %08lx\n", hi
);
917 ok(!lstrcmpA(str
, "request"), "Expected request, got %s\n", str
);
918 ok(size
== 7, "Expected 7, got %d\n", size
);
920 else if (msg_index
== 4 || msg_index
== 7)
922 ok(hi
== 0, "Expected 0, got %08lx\n", hi
);
923 ok(size
== 0, "Expected empty string, got %d\n", size
);
927 ok(hi
== item
, "Expected item atom, got %08lx\n", hi
);
928 if (msg_index
== 6) todo_wine
930 ok(!lstrcmpA(str
, "poke"), "Expected poke, got %s\n", str
);
931 ok(size
== 4, "Expected 4, got %d\n", size
);
941 ok(msg_index
== 5, "Expected 5, got %d\n", msg_index
);
942 ok(wparam
== (WPARAM
)server_hwnd
, "Expected server hwnd, got %08lx\n", wparam
);
944 UnpackDDElParam(WM_DDE_DATA
, lparam
, &lo
, &hi
);
946 data
= GlobalLock((HGLOBAL
)lo
);
947 ok(data
->unused
== 0, "Expected 0, got %d\n", data
->unused
);
948 ok(data
->fResponse
== TRUE
, "Expected TRUE, got %d\n", data
->fResponse
);
951 ok(data
->fRelease
== TRUE
, "Expected TRUE, got %d\n", data
->fRelease
);
953 ok(data
->fAckReq
== 0, "Expected 0, got %d\n", data
->fAckReq
);
954 ok(data
->cfFormat
== CF_TEXT
, "Expected CF_TEXT, got %d\n", data
->cfFormat
);
955 ok(!lstrcmpA((LPSTR
)data
->Value
, "requested data\r\n"),
956 "Expeted 'requested data\\r\\n', got %s\n", data
->Value
);
957 GlobalUnlock((HGLOBAL
)lo
);
959 size
= GlobalGetAtomNameA(hi
, str
, MAX_PATH
);
960 ok(hi
== item
, "Expected item atom, got %08x\n", HIWORD(lparam
));
961 ok(!lstrcmpA(str
, "request"), "Expected request, got %s\n", str
);
962 ok(size
== 7, "Expected 7, got %d\n", size
);
964 GlobalFree((HGLOBAL
)lo
);
965 GlobalDeleteAtom(hi
);
971 ok(FALSE
, "Unhandled msg: %08x\n", msg
);
974 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
977 static HGLOBAL
create_poke()
983 size
= FIELD_OFFSET(DDEPOKE
, Value
[sizeof("poke data\r\n")]);
984 hglobal
= GlobalAlloc(GMEM_DDESHARE
, size
);
985 ok(hglobal
!= 0, "Expected non-NULL hglobal\n");
987 poke
= GlobalLock(hglobal
);
989 poke
->fRelease
= TRUE
;
990 poke
->fReserved
= TRUE
;
991 poke
->cfFormat
= CF_TEXT
;
992 lstrcpyA((LPSTR
)poke
->Value
, "poke data\r\n");
993 GlobalUnlock(hglobal
);
998 static HGLOBAL
create_execute(LPCSTR command
)
1003 hglobal
= GlobalAlloc(GMEM_DDESHARE
, lstrlenA(command
) + 1);
1004 ok(hglobal
!= 0, "Expected non-NULL hglobal\n");
1006 ptr
= GlobalLock(hglobal
);
1007 lstrcpyA(ptr
, command
);
1008 GlobalUnlock(hglobal
);
1013 static void test_msg_client()
1018 create_dde_window(&client_hwnd
, "dde_client", dde_msg_client_wndproc
);
1020 server
= GlobalAddAtomA("TestDDEServer");
1021 ok(server
!= 0, "Expected non-NULL server\n");
1023 topic
= GlobalAddAtomA("TestDDETopic");
1024 ok(topic
!= 0, "Expected non-NULL topic\n");
1026 SendMessageA(HWND_BROADCAST
, WM_DDE_INITIATE
, (WPARAM
)client_hwnd
, MAKELONG(server
, topic
));
1028 GlobalDeleteAtom(server
);
1029 GlobalDeleteAtom(topic
);
1033 item
= GlobalAddAtom("request");
1034 ok(item
!= 0, "Expected non-NULL item\n");
1036 /* WM_DDE_REQUEST, bad clipboard format */
1037 lparam
= PackDDElParam(WM_DDE_REQUEST
, 0xdeadbeef, item
);
1038 PostMessageA(server_hwnd
, WM_DDE_REQUEST
, (WPARAM
)client_hwnd
, lparam
);
1042 /* WM_DDE_REQUEST, no item */
1043 lparam
= PackDDElParam(WM_DDE_REQUEST
, CF_TEXT
, 0);
1044 PostMessageA(server_hwnd
, WM_DDE_REQUEST
, (WPARAM
)client_hwnd
, lparam
);
1048 /* WM_DDE_REQUEST, no client hwnd */
1049 lparam
= PackDDElParam(WM_DDE_REQUEST
, CF_TEXT
, item
);
1050 PostMessageA(server_hwnd
, WM_DDE_REQUEST
, 0, lparam
);
1054 /* WM_DDE_REQUEST, correct params */
1055 lparam
= PackDDElParam(WM_DDE_REQUEST
, CF_TEXT
, item
);
1056 PostMessageA(server_hwnd
, WM_DDE_REQUEST
, (WPARAM
)client_hwnd
, lparam
);
1060 GlobalDeleteAtom(item
);
1061 item
= GlobalAddAtomA("poke");
1062 ok(item
!= 0, "Expected non-NULL item\n");
1064 hglobal
= create_poke();
1066 /* WM_DDE_POKE, no ddepoke */
1067 lparam
= PackDDElParam(WM_DDE_POKE
, 0, item
);
1068 PostMessageA(server_hwnd
, WM_DDE_POKE
, (WPARAM
)client_hwnd
, lparam
);
1072 /* WM_DDE_POKE, no item */
1073 lparam
= PackDDElParam(WM_DDE_POKE
, (UINT_PTR
)hglobal
, 0);
1074 PostMessageA(server_hwnd
, WM_DDE_POKE
, (WPARAM
)client_hwnd
, lparam
);
1078 hglobal
= create_poke();
1080 /* WM_DDE_POKE, no client hwnd */
1081 lparam
= PackDDElParam(WM_DDE_POKE
, (UINT_PTR
)hglobal
, item
);
1082 PostMessageA(server_hwnd
, WM_DDE_POKE
, 0, lparam
);
1086 /* WM_DDE_POKE, all params correct */
1087 lparam
= PackDDElParam(WM_DDE_POKE
, (UINT_PTR
)hglobal
, item
);
1088 PostMessageA(server_hwnd
, WM_DDE_POKE
, (WPARAM
)client_hwnd
, lparam
);
1092 execute_hglobal
= create_execute("[Command(Var)]");
1094 /* WM_DDE_EXECUTE, no lparam */
1095 PostMessageA(server_hwnd
, WM_DDE_EXECUTE
, (WPARAM
)client_hwnd
, 0);
1099 /* WM_DDE_EXECUTE, no hglobal */
1100 lparam
= PackDDElParam(WM_DDE_EXECUTE
, 0, 0);
1101 PostMessageA(server_hwnd
, WM_DDE_EXECUTE
, (WPARAM
)client_hwnd
, lparam
);
1105 /* WM_DDE_EXECUTE, no client hwnd */
1106 lparam
= PackDDElParam(WM_DDE_EXECUTE
, 0, (UINT_PTR
)execute_hglobal
);
1107 PostMessageA(server_hwnd
, WM_DDE_EXECUTE
, 0, lparam
);
1111 /* WM_DDE_EXECUTE, all params correct */
1112 lparam
= PackDDElParam(WM_DDE_EXECUTE
, 0, (UINT_PTR
)execute_hglobal
);
1113 PostMessageA(server_hwnd
, WM_DDE_EXECUTE
, (WPARAM
)client_hwnd
, lparam
);
1117 GlobalFree(execute_hglobal
);
1118 execute_hglobal
= create_execute("[BadCommand(Var)]");
1120 /* WM_DDE_EXECUTE that will get rejected */
1121 lparam
= PackDDElParam(WM_DDE_EXECUTE
, 0, (UINT_PTR
)execute_hglobal
);
1122 PostMessageA(server_hwnd
, WM_DDE_EXECUTE
, (WPARAM
)client_hwnd
, lparam
);
1126 DestroyWindow(client_hwnd
);
1129 static LRESULT WINAPI
hook_dde_client_wndproc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1133 trace("hook_dde_client_wndproc: %p %04x %08lx %08lx\n", hwnd
, msg
, wparam
, lparam
);
1138 UnpackDDElParam(WM_DDE_ACK
, lparam
, &lo
, &hi
);
1139 trace("WM_DDE_ACK: status %04lx hglobal %p\n", lo
, (HGLOBAL
)hi
);
1145 return CallWindowProcA(old_dde_client_wndproc
, hwnd
, msg
, wparam
, lparam
);
1148 static LRESULT WINAPI
dde_server_wndprocW(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1150 trace("dde_server_wndprocW: %p %04x %08lx %08lx\n", hwnd
, msg
, wparam
, lparam
);
1154 case WM_DDE_INITIATE
:
1156 ATOM aService
= GlobalAddAtomW(TEST_DDE_SERVICE
);
1158 trace("server: got WM_DDE_INITIATE from %p with %08lx\n", (HWND
)wparam
, lparam
);
1160 if (LOWORD(lparam
) == aService
)
1162 ok(!IsWindowUnicode((HWND
)wparam
), "client should be an ANSI window\n");
1163 old_dde_client_wndproc
= (WNDPROC
)SetWindowLongPtrA((HWND
)wparam
, GWLP_WNDPROC
, (ULONG_PTR
)hook_dde_client_wndproc
);
1164 trace("server: sending WM_DDE_ACK to %p\n", (HWND
)wparam
);
1165 SendMessageW((HWND
)wparam
, WM_DDE_ACK
, (WPARAM
)hwnd
, MAKELPARAM(aService
, 0));
1168 GlobalDeleteAtom(aService
);
1172 case WM_DDE_EXECUTE
:
1179 trace("server: got WM_DDE_EXECUTE from %p with %08lx\n", (HWND
)wparam
, lparam
);
1181 UnpackDDElParam(WM_DDE_EXECUTE
, lparam
, &lo
, &hi
);
1182 trace("%08lx => lo %04lx hi %04lx\n", lparam
, lo
, hi
);
1184 ack
.bAppReturnCode
= 0;
1188 cmd
= GlobalLock((HGLOBAL
)hi
);
1190 if (!cmd
|| (lstrcmpA(cmd
, exec_cmdA
) && lstrcmpW((LPCWSTR
)cmd
, exec_cmdW
)))
1192 trace("ignoring unknown WM_DDE_EXECUTE command\n");
1193 /* We have to send a negative acknowledge even if we don't
1194 * accept the command, otherwise Windows goes mad and next time
1195 * we send an acknowledge DDEML drops the connection.
1196 * Not sure how to call it: a bug or a feature.
1202 GlobalUnlock((HGLOBAL
)hi
);
1204 trace("server: posting %s WM_DDE_ACK to %p\n", ack
.fAck
? "POSITIVE" : "NEGATIVE", (HWND
)wparam
);
1206 status
= *((WORD
*)&ack
);
1207 lparam
= ReuseDDElParam(lparam
, WM_DDE_EXECUTE
, WM_DDE_ACK
, status
, hi
);
1209 PostMessageW((HWND
)wparam
, WM_DDE_ACK
, (WPARAM
)hwnd
, lparam
);
1213 case WM_DDE_TERMINATE
:
1218 trace("server: got WM_DDE_TERMINATE from %p with %08lx\n", (HWND
)wparam
, lparam
);
1220 ack
.bAppReturnCode
= 0;
1225 trace("server: posting %s WM_DDE_ACK to %p\n", ack
.fAck
? "POSITIVE" : "NEGATIVE", (HWND
)wparam
);
1227 status
= *((WORD
*)&ack
);
1228 lparam
= PackDDElParam(WM_DDE_ACK
, status
, 0);
1230 PostMessageW((HWND
)wparam
, WM_DDE_ACK
, (WPARAM
)hwnd
, lparam
);
1238 return DefWindowProcW(hwnd
, msg
, wparam
, lparam
);
1241 static LRESULT WINAPI
dde_client_wndproc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1243 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
1246 static BOOL
create_dde_windows(HWND
*client
, HWND
*server
)
1250 static const WCHAR server_class_name
[] = {'d','d','e','_','s','e','r','v','e','r','_','w','i','n','d','o','w',0};
1251 static const char client_class_name
[] = "dde_client_window";
1253 memset(&wcW
, 0, sizeof(wcW
));
1254 wcW
.lpfnWndProc
= dde_server_wndprocW
;
1255 wcW
.lpszClassName
= server_class_name
;
1256 wcW
.hInstance
= GetModuleHandleA(0);
1257 if (!RegisterClassW(&wcW
)) return FALSE
;
1259 memset(&wcA
, 0, sizeof(wcA
));
1260 wcA
.lpfnWndProc
= dde_client_wndproc
;
1261 wcA
.lpszClassName
= client_class_name
;
1262 wcA
.hInstance
= GetModuleHandleA(0);
1263 assert(RegisterClassA(&wcA
));
1265 *server
= CreateWindowExW(0, server_class_name
, NULL
,
1267 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
,
1268 GetDesktopWindow(), 0,
1269 GetModuleHandleA(0), NULL
);
1272 *client
= CreateWindowExA(0, client_class_name
, NULL
,
1274 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
,
1275 GetDesktopWindow(), 0,
1276 GetModuleHandleA(0), NULL
);
1279 trace("server hwnd %p, client hwnd %p\n", *server
, *client
);
1281 ok(IsWindowUnicode(*server
), "server has to be a unicode window\n");
1282 ok(!IsWindowUnicode(*client
), "client has to be an ANSI window\n");
1287 static HDDEDATA CALLBACK
client_dde_callback(UINT uType
, UINT uFmt
, HCONV hconv
,
1288 HSZ hsz1
, HSZ hsz2
, HDDEDATA hdata
,
1289 ULONG_PTR dwData1
, ULONG_PTR dwData2
)
1291 static const char * const cmd_type
[15] = {
1292 "XTYP_ERROR", "XTYP_ADVDATA", "XTYP_ADVREQ", "XTYP_ADVSTART",
1293 "XTYP_ADVSTOP", "XTYP_EXECUTE", "XTYP_CONNECT", "XTYP_CONNECT_CONFIRM",
1294 "XTYP_XACT_COMPLETE", "XTYP_POKE", "XTYP_REGISTER", "XTYP_REQUEST",
1295 "XTYP_DISCONNECT", "XTYP_UNREGISTER", "XTYP_WILDCONNECT" };
1297 const char *cmd_name
;
1299 type
= (uType
& XTYP_MASK
) >> XTYP_SHIFT
;
1300 cmd_name
= (type
<= 14) ? cmd_type
[type
] : "unknown";
1302 trace("client_dde_callback: %04x (%s) %d %p %p %p %p %08lx %08lx\n",
1303 uType
, cmd_name
, uFmt
, hconv
, hsz1
, hsz2
, hdata
, dwData1
, dwData2
);
1307 static void test_dde_aw_transaction(void)
1310 DWORD dde_inst
, ret
, err
;
1312 HWND hwnd_client
, hwnd_server
;
1315 static char test_cmd
[] = "test dde command";
1317 /* server: unicode, client: ansi */
1318 if (!create_dde_windows(&hwnd_client
, &hwnd_server
)) return;
1321 ret
= DdeInitializeA(&dde_inst
, client_dde_callback
, APPCMD_CLIENTONLY
, 0);
1322 ok(ret
== DMLERR_NO_ERROR
, "DdeInitializeW failed with error %04x (%x)\n",
1323 ret
, DdeGetLastError(dde_inst
));
1325 hsz_server
= DdeCreateStringHandleW(dde_inst
, TEST_DDE_SERVICE
, CP_WINUNICODE
);
1327 hconv
= DdeConnect(dde_inst
, hsz_server
, 0, NULL
);
1328 ok(hconv
!= 0, "DdeConnect error %x\n", DdeGetLastError(dde_inst
));
1329 err
= DdeGetLastError(dde_inst
);
1330 ok(err
== DMLERR_NO_ERROR
, "wrong dde error %x\n", err
);
1332 info
.cb
= sizeof(info
);
1333 ret
= DdeQueryConvInfo(hconv
, QID_SYNC
, &info
);
1334 ok(ret
, "wrong info size %d, DdeQueryConvInfo error %x\n", ret
, DdeGetLastError(dde_inst
));
1335 /* should be CP_WINANSI since we used DdeInitializeA */
1336 ok(info
.ConvCtxt
.iCodePage
== CP_WINANSI
, "wrong iCodePage %d\n", info
.ConvCtxt
.iCodePage
);
1337 ok(!info
.hConvPartner
, "unexpected info.hConvPartner: %p\n", info
.hConvPartner
);
1339 ok((info
.wStatus
& DDE_FACK
), "unexpected info.wStatus: %04x\n", info
.wStatus
);
1341 ok((info
.wStatus
& (ST_CONNECTED
| ST_CLIENT
)) == (ST_CONNECTED
| ST_CLIENT
), "unexpected info.wStatus: %04x\n", info
.wStatus
);
1342 ok(info
.wConvst
== XST_CONNECTED
, "unexpected info.wConvst: %04x\n", info
.wConvst
);
1343 ok(info
.wType
== 0, "unexpected info.wType: %04x\n", info
.wType
);
1345 trace("hwnd %p, hwndPartner %p\n", info
.hwnd
, info
.hwndPartner
);
1347 trace("sending test client transaction command\n");
1349 hdata
= DdeClientTransaction((LPBYTE
)test_cmd
, strlen(test_cmd
) + 1, hconv
, (HSZ
)0xdead, 0xbeef, XTYP_EXECUTE
, 1000, &ret
);
1350 ok(!hdata
, "DdeClientTransaction succeeded\n");
1351 ok(ret
== DDE_FNOTPROCESSED
, "wrong status code %04x\n", ret
);
1352 err
= DdeGetLastError(dde_inst
);
1353 ok(err
== DMLERR_NOTPROCESSED
, "wrong dde error %x\n", err
);
1355 trace("sending ANSI client transaction command\n");
1357 hdata
= DdeClientTransaction((LPBYTE
)exec_cmdA
, lstrlenA(exec_cmdA
) + 1, hconv
, 0, 0, XTYP_EXECUTE
, 1000, &ret
);
1358 ok(hdata
!= 0, "DdeClientTransaction returned %p, error %x\n", hdata
, DdeGetLastError(dde_inst
));
1359 ok(ret
== DDE_FACK
, "wrong status code %04x\n", ret
);
1361 err
= DdeGetLastError(dde_inst
);
1362 ok(err
== DMLERR_NO_ERROR
, "wrong dde error %x\n", err
);
1364 trace("sending unicode client transaction command\n");
1366 hdata
= DdeClientTransaction((LPBYTE
)exec_cmdW
, (lstrlenW(exec_cmdW
) + 1) * sizeof(WCHAR
), hconv
, 0, 0, XTYP_EXECUTE
, 1000, &ret
);
1367 ok(hdata
!= 0, "DdeClientTransaction returned %p, error %x\n", hdata
, DdeGetLastError(dde_inst
));
1368 ok(ret
== DDE_FACK
, "wrong status code %04x\n", ret
);
1369 err
= DdeGetLastError(dde_inst
);
1370 ok(err
== DMLERR_NO_ERROR
, "wrong dde error %x\n", err
);
1372 ok(DdeDisconnect(hconv
), "DdeDisconnect error %x\n", DdeGetLastError(dde_inst
));
1374 info
.cb
= sizeof(info
);
1375 ret
= DdeQueryConvInfo(hconv
, QID_SYNC
, &info
);
1376 ok(!ret
, "DdeQueryConvInfo should fail\n");
1377 err
= DdeGetLastError(dde_inst
);
1379 ok(err
== DMLERR_INVALIDPARAMETER
, "wrong dde error %x\n", err
);
1382 ok(DdeFreeStringHandle(dde_inst
, hsz_server
), "DdeFreeStringHandle error %x\n", DdeGetLastError(dde_inst
));
1384 /* This call hangs on win2k SP4 and XP SP1.
1385 DdeUninitialize(dde_inst);*/
1387 DestroyWindow(hwnd_client
);
1388 DestroyWindow(hwnd_server
);
1391 static void test_DdeCreateStringHandleW(DWORD dde_inst
, int codepage
)
1393 static const WCHAR dde_string
[] = {'D','D','E',' ','S','t','r','i','n','g',0};
1400 str_handle
= DdeCreateStringHandleW(dde_inst
, dde_string
, codepage
);
1401 ok(str_handle
!= 0, "DdeCreateStringHandleW failed with error %08x\n",
1402 DdeGetLastError(dde_inst
));
1404 ret
= DdeQueryStringW(dde_inst
, str_handle
, NULL
, 0, codepage
);
1405 if (codepage
== CP_WINANSI
)
1406 ok(ret
== 1, "DdeQueryStringW returned wrong length %d\n", ret
);
1408 ok(ret
== lstrlenW(dde_string
), "DdeQueryStringW returned wrong length %d\n", ret
);
1410 ret
= DdeQueryStringW(dde_inst
, str_handle
, bufW
, 256, codepage
);
1411 if (codepage
== CP_WINANSI
)
1413 ok(ret
== 1, "DdeQueryStringW returned wrong length %d\n", ret
);
1414 ok(!lstrcmpA("D", (LPCSTR
)bufW
), "DdeQueryStringW returned wrong string\n");
1418 ok(ret
== lstrlenW(dde_string
), "DdeQueryStringW returned wrong length %d\n", ret
);
1419 ok(!lstrcmpW(dde_string
, bufW
), "DdeQueryStringW returned wrong string\n");
1422 ret
= DdeQueryStringA(dde_inst
, str_handle
, buf
, 256, CP_WINANSI
);
1423 if (codepage
== CP_WINANSI
)
1425 ok(ret
== 1, "DdeQueryStringA returned wrong length %d\n", ret
);
1426 ok(!lstrcmpA("D", buf
), "DdeQueryStringW returned wrong string\n");
1430 ok(ret
== lstrlenA("DDE String"), "DdeQueryStringA returned wrong length %d\n", ret
);
1431 ok(!lstrcmpA("DDE String", buf
), "DdeQueryStringA returned wrong string %s\n", buf
);
1434 ret
= DdeQueryStringA(dde_inst
, str_handle
, buf
, 256, CP_WINUNICODE
);
1435 if (codepage
== CP_WINANSI
)
1437 ok(ret
== 1, "DdeQueryStringA returned wrong length %d\n", ret
);
1438 ok(!lstrcmpA("D", buf
), "DdeQueryStringA returned wrong string %s\n", buf
);
1442 ok(ret
== lstrlenA("DDE String"), "DdeQueryStringA returned wrong length %d\n", ret
);
1443 ok(!lstrcmpW(dde_string
, (LPCWSTR
)buf
), "DdeQueryStringW returned wrong string\n");
1446 if (codepage
== CP_WINANSI
)
1448 atom
= FindAtomA((LPSTR
)dde_string
);
1449 ok(atom
!= 0, "Expected a valid atom\n");
1451 SetLastError(0xdeadbeef);
1452 atom
= GlobalFindAtomA((LPSTR
)dde_string
);
1453 ok(atom
== 0, "Expected 0, got %d\n", atom
);
1454 ok(GetLastError() == ERROR_FILE_NOT_FOUND
,
1455 "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
1459 atom
= FindAtomW(dde_string
);
1460 ok(atom
!= 0, "Expected a valid atom\n");
1462 SetLastError(0xdeadbeef);
1463 atom
= GlobalFindAtomW(dde_string
);
1464 ok(atom
== 0, "Expected 0, got %d\n", atom
);
1465 ok(GetLastError() == ERROR_FILE_NOT_FOUND
,
1466 "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
1469 ok(DdeFreeStringHandle(dde_inst
, str_handle
), "DdeFreeStringHandle failed\n");
1472 static void test_DdeCreateDataHandle(void)
1483 res
= DdeInitializeA(&dde_inst
, client_ddeml_callback
, APPCMD_CLIENTONLY
, 0);
1484 ok(res
== DMLERR_NO_ERROR
, "Expected DMLERR_NO_ERROR, got %d\n", res
);
1486 item
= DdeCreateStringHandleA(dde_inst
, "item", CP_WINANSI
);
1487 ok(item
!= NULL
, "Expected non-NULL hsz\n");
1489 /* invalid instance id */
1490 DdeGetLastError(dde_inst
);
1491 hdata
= DdeCreateDataHandle(0xdeadbeef, (LPBYTE
)"data", MAX_PATH
, 0, item
, CF_TEXT
, 0);
1492 err
= DdeGetLastError(dde_inst
);
1495 ok(hdata
== NULL
, "Expected NULL, got %p\n", hdata
);
1496 ok(err
== DMLERR_INVALIDPARAMETER
,
1497 "Expected DMLERR_INVALIDPARAMETER, got %d\n", err
);
1501 DdeGetLastError(dde_inst
);
1502 hdata
= DdeCreateDataHandle(0, (LPBYTE
)"data", MAX_PATH
, 0, item
, CF_TEXT
, 0);
1503 err
= DdeGetLastError(dde_inst
);
1506 ok(hdata
== NULL
, "Expected NULL, got %p\n", hdata
);
1507 ok(err
== DMLERR_INVALIDPARAMETER
,
1508 "Expected DMLERR_INVALIDPARAMETER, got %d\n", err
);
1512 DdeGetLastError(dde_inst
);
1513 hdata
= DdeCreateDataHandle(dde_inst
, NULL
, MAX_PATH
, 0, item
, CF_TEXT
, 0);
1514 err
= DdeGetLastError(dde_inst
);
1515 ok(hdata
!= NULL
, "Expected non-NULL hdata\n");
1516 ok(err
== DMLERR_NO_ERROR
, "Expected DMLERR_NO_ERROR, got %d\n", err
);
1518 ptr
= GlobalLock(hdata
);
1521 ok(ptr
== NULL
, "Expected NULL, got %p\n", ptr
);
1524 ptr
= DdeAccessData(hdata
, &size
);
1525 ok(ptr
!= NULL
, "Expected non-NULL ptr\n");
1526 ok(size
== 260, "Expected 260, got %d\n", size
);
1528 ret
= DdeUnaccessData(hdata
);
1529 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1531 ret
= DdeFreeDataHandle(hdata
);
1532 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1535 DdeGetLastError(dde_inst
);
1536 hdata
= DdeCreateDataHandle(dde_inst
, (LPBYTE
)"data", 0, 0, item
, CF_TEXT
, 0);
1537 err
= DdeGetLastError(dde_inst
);
1538 ok(hdata
!= NULL
, "Expected non-NULL hdata\n");
1539 ok(err
== DMLERR_NO_ERROR
, "Expected DMLERR_NO_ERROR, got %d\n", err
);
1541 ptr
= GlobalLock(hdata
);
1544 ok(ptr
== NULL
, "Expected NULL, got %p\n", ptr
);
1547 ptr
= DdeAccessData(hdata
, &size
);
1548 ok(ptr
!= NULL
, "Expected non-NULL ptr\n");
1549 ok(size
== 0, "Expected 0, got %d\n", size
);
1551 ret
= DdeUnaccessData(hdata
);
1552 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1554 ret
= DdeFreeDataHandle(hdata
);
1555 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1557 /* cbOff is non-zero */
1558 DdeGetLastError(dde_inst
);
1559 hdata
= DdeCreateDataHandle(dde_inst
, (LPBYTE
)"data", MAX_PATH
, 2, item
, CF_TEXT
, 0);
1560 err
= DdeGetLastError(dde_inst
);
1561 ok(hdata
!= NULL
, "Expected non-NULL hdata\n");
1562 ok(err
== DMLERR_NO_ERROR
, "Expected DMLERR_NO_ERROR, got %d\n", err
);
1564 ptr
= GlobalLock(hdata
);
1567 ok(ptr
== NULL
, "Expected NULL, got %p\n", ptr
);
1570 ptr
= DdeAccessData(hdata
, &size
);
1571 ok(ptr
!= NULL
, "Expected non-NULL ptr\n");
1572 ok(size
== 262, "Expected 262, got %d\n", size
);
1575 ok(lstrlenA((LPSTR
)ptr
) == 0, "Expected 0, got %d\n", lstrlenA((LPSTR
)ptr
));
1578 ret
= DdeUnaccessData(hdata
);
1579 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1581 ret
= DdeFreeDataHandle(hdata
);
1582 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1585 DdeGetLastError(dde_inst
);
1586 hdata
= DdeCreateDataHandle(dde_inst
, (LPBYTE
)"data", MAX_PATH
, 0, 0, CF_TEXT
, 0);
1587 err
= DdeGetLastError(dde_inst
);
1588 ok(hdata
!= NULL
, "Expected non-NULL hdata\n");
1589 ok(err
== DMLERR_NO_ERROR
, "Expected DMLERR_NO_ERROR, got %d\n", err
);
1591 ptr
= GlobalLock(hdata
);
1594 ok(ptr
== NULL
, "Expected NULL, got %p\n", ptr
);
1597 ptr
= DdeAccessData(hdata
, &size
);
1598 ok(ptr
!= NULL
, "Expected non-NULL ptr\n");
1599 ok(!lstrcmpA((LPSTR
)ptr
, "data"), "Expected data, got %s\n", ptr
);
1600 ok(size
== 260, "Expected 260, got %d\n", size
);
1602 ret
= DdeUnaccessData(hdata
);
1603 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1605 ret
= DdeFreeDataHandle(hdata
);
1606 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1609 DdeGetLastError(dde_inst
);
1610 hdata
= DdeCreateDataHandle(dde_inst
, (LPBYTE
)"data", MAX_PATH
, 0, (HSZ
)0xdeadbeef, CF_TEXT
, 0);
1611 err
= DdeGetLastError(dde_inst
);
1612 ok(hdata
!= NULL
, "Expected non-NULL hdata\n");
1613 ok(err
== DMLERR_NO_ERROR
, "Expected DMLERR_NO_ERROR, got %d\n", err
);
1615 ptr
= GlobalLock(hdata
);
1618 ok(ptr
== NULL
, "Expected NULL, got %p\n", ptr
);
1621 ptr
= DdeAccessData(hdata
, &size
);
1622 ok(ptr
!= NULL
, "Expected non-NULL ptr\n");
1623 ok(!lstrcmpA((LPSTR
)ptr
, "data"), "Expected data, got %s\n", ptr
);
1624 ok(size
== 260, "Expected 260, got %d\n", size
);
1626 ret
= DdeUnaccessData(hdata
);
1627 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1629 ret
= DdeFreeDataHandle(hdata
);
1630 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1632 /* invalid clipboard format */
1633 DdeGetLastError(dde_inst
);
1634 hdata
= DdeCreateDataHandle(dde_inst
, (LPBYTE
)"data", MAX_PATH
, 0, item
, 0xdeadbeef, 0);
1635 err
= DdeGetLastError(dde_inst
);
1636 ok(hdata
!= NULL
, "Expected non-NULL hdata\n");
1637 ok(err
== DMLERR_NO_ERROR
, "Expected DMLERR_NO_ERROR, got %d\n", err
);
1639 ptr
= GlobalLock(hdata
);
1642 ok(ptr
== NULL
, "Expected NULL, got %p\n", ptr
);
1645 ptr
= DdeAccessData(hdata
, &size
);
1646 ok(ptr
!= NULL
, "Expected non-NULL ptr\n");
1647 ok(!lstrcmpA((LPSTR
)ptr
, "data"), "Expected data, got %s\n", ptr
);
1648 ok(size
== 260, "Expected 260, got %d\n", size
);
1650 ret
= DdeUnaccessData(hdata
);
1651 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1653 ret
= DdeFreeDataHandle(hdata
);
1654 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1656 ret
= DdeUninitialize(dde_inst
);
1657 ok(res
== DMLERR_NO_ERROR
, "Expected DMLERR_NO_ERROR, got %d\n", res
);
1660 static void test_DdeCreateStringHandle(void)
1662 DWORD dde_inst
, ret
;
1664 dde_inst
= 0xdeadbeef;
1665 SetLastError(0xdeadbeef);
1666 ret
= DdeInitializeW(&dde_inst
, client_ddeml_callback
, APPCMD_CLIENTONLY
, 0);
1667 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1669 trace("Skipping the DDE test on a Win9x platform\n");
1673 ok(ret
== DMLERR_INVALIDPARAMETER
, "DdeInitializeW should fail, but got %04x instead\n", ret
);
1674 ok(DdeGetLastError(dde_inst
) == DMLERR_INVALIDPARAMETER
, "expected DMLERR_INVALIDPARAMETER\n");
1677 ret
= DdeInitializeW(&dde_inst
, client_ddeml_callback
, APPCMD_CLIENTONLY
, 0);
1678 ok(ret
== DMLERR_NO_ERROR
, "DdeInitializeW failed with error %04x (%08x)\n",
1679 ret
, DdeGetLastError(dde_inst
));
1681 test_DdeCreateStringHandleW(dde_inst
, 0);
1682 test_DdeCreateStringHandleW(dde_inst
, CP_WINUNICODE
);
1683 test_DdeCreateStringHandleW(dde_inst
, CP_WINANSI
);
1685 ok(DdeUninitialize(dde_inst
), "DdeUninitialize failed\n");
1688 static void test_FreeDDElParam(void)
1690 HGLOBAL val
, hglobal
;
1693 ret
= FreeDDElParam(WM_DDE_INITIATE
, (LPARAM
)NULL
);
1694 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1696 hglobal
= GlobalAlloc(GMEM_DDESHARE
, 100);
1697 ret
= FreeDDElParam(WM_DDE_INITIATE
, (LPARAM
)hglobal
);
1698 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1699 val
= GlobalFree(hglobal
);
1700 ok(val
== NULL
, "Expected NULL, got %p\n", val
);
1702 hglobal
= GlobalAlloc(GMEM_DDESHARE
, 100);
1703 ret
= FreeDDElParam(WM_DDE_ADVISE
, (LPARAM
)hglobal
);
1704 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1705 val
= GlobalFree(hglobal
);
1706 ok(val
== hglobal
, "Expected hglobal, got %p\n", val
);
1707 ok(GetLastError() == ERROR_INVALID_HANDLE
,
1708 "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
1710 hglobal
= GlobalAlloc(GMEM_DDESHARE
, 100);
1711 ret
= FreeDDElParam(WM_DDE_UNADVISE
, (LPARAM
)hglobal
);
1712 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1713 val
= GlobalFree(hglobal
);
1714 ok(val
== NULL
, "Expected NULL, got %p\n", val
);
1716 hglobal
= GlobalAlloc(GMEM_DDESHARE
, 100);
1717 ret
= FreeDDElParam(WM_DDE_ACK
, (LPARAM
)hglobal
);
1718 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1719 val
= GlobalFree(hglobal
);
1720 ok(val
== hglobal
, "Expected hglobal, got %p\n", val
);
1721 ok(GetLastError() == ERROR_INVALID_HANDLE
,
1722 "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
1724 hglobal
= GlobalAlloc(GMEM_DDESHARE
, 100);
1725 ret
= FreeDDElParam(WM_DDE_DATA
, (LPARAM
)hglobal
);
1726 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1727 val
= GlobalFree(hglobal
);
1728 ok(val
== hglobal
, "Expected hglobal, got %p\n", val
);
1729 ok(GetLastError() == ERROR_INVALID_HANDLE
,
1730 "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
1732 hglobal
= GlobalAlloc(GMEM_DDESHARE
, 100);
1733 ret
= FreeDDElParam(WM_DDE_REQUEST
, (LPARAM
)hglobal
);
1734 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1735 val
= GlobalFree(hglobal
);
1736 ok(val
== NULL
, "Expected NULL, got %p\n", val
);
1738 hglobal
= GlobalAlloc(GMEM_DDESHARE
, 100);
1739 ret
= FreeDDElParam(WM_DDE_POKE
, (LPARAM
)hglobal
);
1740 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1741 val
= GlobalFree(hglobal
);
1742 ok(val
== hglobal
, "Expected hglobal, got %p\n", val
);
1743 ok(GetLastError() == ERROR_INVALID_HANDLE
,
1744 "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
1746 hglobal
= GlobalAlloc(GMEM_DDESHARE
, 100);
1747 ret
= FreeDDElParam(WM_DDE_EXECUTE
, (LPARAM
)hglobal
);
1748 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1749 val
= GlobalFree(hglobal
);
1750 ok(val
== NULL
, "Expected NULL, got %p\n", val
);
1753 static void test_PackDDElParam(void)
1755 UINT_PTR lo
, hi
, *ptr
;
1760 lparam
= PackDDElParam(WM_DDE_INITIATE
, 0xcafe, 0xbeef);
1761 ok(lparam
== 0xbeefcafe, "Expected 0xbeefcafe, got %08lx\n", lparam
);
1762 ok(GlobalLock((HGLOBAL
)lparam
) == NULL
,
1763 "Expected NULL, got %p\n", GlobalLock((HGLOBAL
)lparam
));
1764 ok(GetLastError() == ERROR_INVALID_HANDLE
,
1765 "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
1768 ret
= UnpackDDElParam(WM_DDE_INITIATE
, lparam
, &lo
, &hi
);
1769 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1770 ok(lo
== 0xcafe, "Expected 0xcafe, got %08lx\n", lo
);
1771 ok(hi
== 0xbeef, "Expected 0xbeef, got %08lx\n", hi
);
1773 ret
= FreeDDElParam(WM_DDE_INITIATE
, lparam
);
1774 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1776 lparam
= PackDDElParam(WM_DDE_TERMINATE
, 0xcafe, 0xbeef);
1777 ok(lparam
== 0xbeefcafe, "Expected 0xbeefcafe, got %08lx\n", lparam
);
1778 ok(GlobalLock((HGLOBAL
)lparam
) == NULL
,
1779 "Expected NULL, got %p\n", GlobalLock((HGLOBAL
)lparam
));
1780 ok(GetLastError() == ERROR_INVALID_HANDLE
,
1781 "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
1784 ret
= UnpackDDElParam(WM_DDE_TERMINATE
, lparam
, &lo
, &hi
);
1785 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1786 ok(lo
== 0xcafe, "Expected 0xcafe, got %08lx\n", lo
);
1787 ok(hi
== 0xbeef, "Expected 0xbeef, got %08lx\n", hi
);
1789 ret
= FreeDDElParam(WM_DDE_TERMINATE
, lparam
);
1790 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1792 lparam
= PackDDElParam(WM_DDE_ADVISE
, 0xcafe, 0xbeef);
1793 ptr
= GlobalLock((HGLOBAL
)lparam
);
1794 ok(ptr
!= NULL
, "Expected non-NULL ptr\n");
1795 ok(ptr
[0] == 0xcafe, "Expected 0xcafe, got %08lx\n", ptr
[0]);
1796 ok(ptr
[1] == 0xbeef, "Expected 0xbeef, got %08lx\n", ptr
[1]);
1798 ret
= GlobalUnlock((HGLOBAL
)lparam
);
1799 ok(ret
== 1, "Expected 1, got %d\n", ret
);
1802 ret
= UnpackDDElParam(WM_DDE_ADVISE
, lparam
, &lo
, &hi
);
1803 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1804 ok(lo
== 0xcafe, "Expected 0xcafe, got %08lx\n", lo
);
1805 ok(hi
== 0xbeef, "Expected 0xbeef, got %08lx\n", hi
);
1807 ret
= FreeDDElParam(WM_DDE_ADVISE
, lparam
);
1808 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1810 hglobal
= GlobalFree((HGLOBAL
)lparam
);
1811 ok(hglobal
== (HGLOBAL
)lparam
, "Expected lparam, got %d\n", ret
);
1812 ok(GetLastError() == ERROR_INVALID_HANDLE
,
1813 "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
1815 lparam
= PackDDElParam(WM_DDE_UNADVISE
, 0xcafe, 0xbeef);
1816 ok(lparam
== 0xbeefcafe, "Expected 0xbeefcafe, got %08lx\n", lparam
);
1817 ok(GlobalLock((HGLOBAL
)lparam
) == NULL
,
1818 "Expected NULL, got %p\n", GlobalLock((HGLOBAL
)lparam
));
1819 ok(GetLastError() == ERROR_INVALID_HANDLE
,
1820 "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
1823 ret
= UnpackDDElParam(WM_DDE_UNADVISE
, lparam
, &lo
, &hi
);
1824 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1825 ok(lo
== 0xcafe, "Expected 0xcafe, got %08lx\n", lo
);
1826 ok(hi
== 0xbeef, "Expected 0xbeef, got %08lx\n", hi
);
1828 ret
= FreeDDElParam(WM_DDE_UNADVISE
, lparam
);
1829 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1831 lparam
= PackDDElParam(WM_DDE_ACK
, 0xcafe, 0xbeef);
1832 ptr
= GlobalLock((HGLOBAL
)lparam
);
1833 ok(ptr
!= NULL
, "Expected non-NULL ptr\n");
1834 ok(ptr
[0] == 0xcafe, "Expected 0xcafe, got %08lx\n", ptr
[0]);
1835 ok(ptr
[1] == 0xbeef, "Expected 0xbeef, got %08lx\n", ptr
[1]);
1837 ret
= GlobalUnlock((HGLOBAL
)lparam
);
1838 ok(ret
== 1, "Expected 1, got %d\n", ret
);
1841 ret
= UnpackDDElParam(WM_DDE_ACK
, lparam
, &lo
, &hi
);
1842 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1843 ok(lo
== 0xcafe, "Expected 0xcafe, got %08lx\n", lo
);
1844 ok(hi
== 0xbeef, "Expected 0xbeef, got %08lx\n", hi
);
1846 ret
= FreeDDElParam(WM_DDE_ACK
, lparam
);
1847 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1849 hglobal
= GlobalFree((HGLOBAL
)lparam
);
1850 ok(hglobal
== (HGLOBAL
)lparam
, "Expected lparam, got %d\n", ret
);
1851 ok(GetLastError() == ERROR_INVALID_HANDLE
,
1852 "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
1854 lparam
= PackDDElParam(WM_DDE_DATA
, 0xcafe, 0xbeef);
1855 ptr
= GlobalLock((HGLOBAL
)lparam
);
1856 ok(ptr
!= NULL
, "Expected non-NULL ptr\n");
1857 ok(ptr
[0] == 0xcafe, "Expected 0xcafe, got %08lx\n", ptr
[0]);
1858 ok(ptr
[1] == 0xbeef, "Expected 0xbeef, got %08lx\n", ptr
[1]);
1860 ret
= GlobalUnlock((HGLOBAL
)lparam
);
1861 ok(ret
== 1, "Expected 1, got %d\n", ret
);
1864 ret
= UnpackDDElParam(WM_DDE_DATA
, lparam
, &lo
, &hi
);
1865 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1866 ok(lo
== 0xcafe, "Expected 0xcafe, got %08lx\n", lo
);
1867 ok(hi
== 0xbeef, "Expected 0xbeef, got %08lx\n", hi
);
1869 ret
= FreeDDElParam(WM_DDE_DATA
, lparam
);
1870 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1872 hglobal
= GlobalFree((HGLOBAL
)lparam
);
1873 ok(hglobal
== (HGLOBAL
)lparam
, "Expected lparam, got %d\n", ret
);
1874 ok(GetLastError() == ERROR_INVALID_HANDLE
,
1875 "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
1877 lparam
= PackDDElParam(WM_DDE_REQUEST
, 0xcafe, 0xbeef);
1878 ok(lparam
== 0xbeefcafe, "Expected 0xbeefcafe, got %08lx\n", lparam
);
1879 ok(GlobalLock((HGLOBAL
)lparam
) == NULL
,
1880 "Expected NULL, got %p\n", GlobalLock((HGLOBAL
)lparam
));
1881 ok(GetLastError() == ERROR_INVALID_HANDLE
,
1882 "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
1885 ret
= UnpackDDElParam(WM_DDE_REQUEST
, lparam
, &lo
, &hi
);
1886 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1887 ok(lo
== 0xcafe, "Expected 0xcafe, got %08lx\n", lo
);
1888 ok(hi
== 0xbeef, "Expected 0xbeef, got %08lx\n", hi
);
1890 ret
= FreeDDElParam(WM_DDE_REQUEST
, lparam
);
1891 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1893 lparam
= PackDDElParam(WM_DDE_POKE
, 0xcafe, 0xbeef);
1894 ptr
= GlobalLock((HGLOBAL
)lparam
);
1895 ok(ptr
!= NULL
, "Expected non-NULL ptr\n");
1896 ok(ptr
[0] == 0xcafe, "Expected 0xcafe, got %08lx\n", ptr
[0]);
1897 ok(ptr
[1] == 0xbeef, "Expected 0xbeef, got %08lx\n", ptr
[1]);
1899 ret
= GlobalUnlock((HGLOBAL
)lparam
);
1900 ok(ret
== 1, "Expected 1, got %d\n", ret
);
1903 ret
= UnpackDDElParam(WM_DDE_POKE
, lparam
, &lo
, &hi
);
1904 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1905 ok(lo
== 0xcafe, "Expected 0xcafe, got %08lx\n", lo
);
1906 ok(hi
== 0xbeef, "Expected 0xbeef, got %08lx\n", hi
);
1908 ret
= FreeDDElParam(WM_DDE_POKE
, lparam
);
1909 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1911 hglobal
= GlobalFree((HGLOBAL
)lparam
);
1912 ok(hglobal
== (HGLOBAL
)lparam
, "Expected lparam, got %d\n", ret
);
1913 ok(GetLastError() == ERROR_INVALID_HANDLE
,
1914 "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
1916 lparam
= PackDDElParam(WM_DDE_EXECUTE
, 0xcafe, 0xbeef);
1917 ok(lparam
== 0xbeef, "Expected 0xbeef, got %08lx\n", lparam
);
1918 ok(GlobalLock((HGLOBAL
)lparam
) == NULL
,
1919 "Expected NULL, got %p\n", GlobalLock((HGLOBAL
)lparam
));
1920 ok(GetLastError() == ERROR_INVALID_HANDLE
,
1921 "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
1924 ret
= UnpackDDElParam(WM_DDE_EXECUTE
, lparam
, &lo
, &hi
);
1925 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1926 ok(lo
== 0, "Expected 0, got %08lx\n", lo
);
1927 ok(hi
== 0xbeef, "Expected 0xbeef, got %08lx\n", hi
);
1929 ret
= FreeDDElParam(WM_DDE_EXECUTE
, lparam
);
1930 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1933 static void test_UnpackDDElParam(void)
1935 UINT_PTR lo
, hi
, *ptr
;
1942 ret
= UnpackDDElParam(WM_DDE_INITIATE
, (LPARAM
)NULL
, &lo
, &hi
);
1943 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1944 ok(lo
== 0, "Expected 0, got %08lx\n", lo
);
1945 ok(hi
== 0, "Expected 0, got %08lx\n", hi
);
1950 ret
= UnpackDDElParam(WM_DDE_INITIATE
, 0xcafebabe, NULL
, &hi
);
1951 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1952 ok(lo
== 0xdead, "Expected 0xdead, got %08lx\n", lo
);
1953 ok(hi
== 0xcafe, "Expected 0xcafe, got %08lx\n", hi
);
1958 ret
= UnpackDDElParam(WM_DDE_INITIATE
, 0xcafebabe, &lo
, NULL
);
1959 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1960 ok(lo
== 0xbabe, "Expected 0xbabe, got %08lx\n", lo
);
1961 ok(hi
== 0xbeef, "Expected 0xbeef, got %08lx\n", hi
);
1965 ret
= UnpackDDElParam(WM_DDE_INITIATE
, 0xcafebabe, &lo
, &hi
);
1966 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1967 ok(lo
== 0xbabe, "Expected 0xbabe, got %08lx\n", lo
);
1968 ok(hi
== 0xcafe, "Expected 0xcafe, got %08lx\n", hi
);
1972 ret
= UnpackDDElParam(WM_DDE_TERMINATE
, 0xcafebabe, &lo
, &hi
);
1973 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
1974 ok(lo
== 0xbabe, "Expected 0xbabe, got %08lx\n", lo
);
1975 ok(hi
== 0xcafe, "Expected 0xcafe, got %08lx\n", hi
);
1979 ret
= UnpackDDElParam(WM_DDE_ADVISE
, (LPARAM
)NULL
, &lo
, &hi
);
1980 ok(ret
== FALSE
, "Expected FALSE, got %d\n", ret
);
1982 broken(lo
== 0xdead), /* win2k */
1983 "Expected 0, got %08lx\n", lo
);
1985 broken(hi
== 0xbeef), /* win2k */
1986 "Expected 0, got %08lx\n", hi
);
1990 ret
= UnpackDDElParam(WM_DDE_ADVISE
, 0xcafebabe, &lo
, &hi
);
1991 ok(ret
== FALSE
, "Expected FALSE, got %d\n", ret
);
1993 broken(lo
== 0xdead), /* win2k */
1994 "Expected 0, got %08lx\n", lo
);
1996 broken(hi
== 0xbeef), /* win2k */
1997 "Expected 0, got %08lx\n", hi
);
1999 hglobal
= GlobalAlloc(GMEM_DDESHARE
, 2);
2000 ptr
= GlobalLock(hglobal
);
2001 ptr
[0] = 0xcafebabe;
2002 ptr
[1] = 0xdeadbeef;
2003 GlobalUnlock(hglobal
);
2007 ret
= UnpackDDElParam(WM_DDE_ADVISE
, (LPARAM
)hglobal
, &lo
, &hi
);
2008 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
2009 ok(lo
== 0xcafebabe, "Expected 0xcafebabe, got %08lx\n", lo
);
2010 ok(hi
== 0xdeadbeef, "Expected 0xdeadbeef, got %08lx\n", hi
);
2014 ret
= UnpackDDElParam(WM_DDE_UNADVISE
, 0xcafebabe, &lo
, &hi
);
2015 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
2016 ok(lo
== 0xbabe, "Expected 0xbabe, got %08lx\n", lo
);
2017 ok(hi
== 0xcafe, "Expected 0xcafe, got %08lx\n", hi
);
2021 ret
= UnpackDDElParam(WM_DDE_ACK
, 0xcafebabe, &lo
, &hi
);
2022 ok(ret
== FALSE
, "Expected FALSE, got %d\n", ret
);
2024 broken(lo
== 0xdead), /* win2k */
2025 "Expected 0, got %08lx\n", lo
);
2027 broken(hi
== 0xbeef), /* win2k */
2028 "Expected 0, got %08lx\n", hi
);
2032 ret
= UnpackDDElParam(WM_DDE_ACK
, (LPARAM
)hglobal
, &lo
, &hi
);
2033 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
2034 ok(lo
== 0xcafebabe, "Expected 0xcafebabe, got %08lx\n", lo
);
2035 ok(hi
== 0xdeadbeef, "Expected 0xdeadbeef, got %08lx\n", hi
);
2039 ret
= UnpackDDElParam(WM_DDE_DATA
, 0xcafebabe, &lo
, &hi
);
2040 ok(ret
== FALSE
, "Expected FALSE, got %d\n", ret
);
2042 broken(lo
== 0xdead), /* win2k */
2043 "Expected 0, got %08lx\n", lo
);
2045 broken(hi
== 0xbeef), /* win2k */
2046 "Expected 0, got %08lx\n", hi
);
2050 ret
= UnpackDDElParam(WM_DDE_DATA
, (LPARAM
)hglobal
, &lo
, &hi
);
2051 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
2052 ok(lo
== 0xcafebabe, "Expected 0xcafebabe, got %08lx\n", lo
);
2053 ok(hi
== 0xdeadbeef, "Expected 0xdeadbeef, got %08lx\n", hi
);
2057 ret
= UnpackDDElParam(WM_DDE_REQUEST
, 0xcafebabe, &lo
, &hi
);
2058 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
2059 ok(lo
== 0xbabe, "Expected 0xbabe, got %08lx\n", lo
);
2060 ok(hi
== 0xcafe, "Expected 0xcafe, got %08lx\n", hi
);
2064 ret
= UnpackDDElParam(WM_DDE_POKE
, 0xcafebabe, &lo
, &hi
);
2065 ok(ret
== FALSE
, "Expected FALSE, got %d\n", ret
);
2067 broken(lo
== 0xdead), /* win2k */
2068 "Expected 0, got %08lx\n", lo
);
2070 broken(hi
== 0xbeef), /* win2k */
2071 "Expected 0, got %08lx\n", hi
);
2075 ret
= UnpackDDElParam(WM_DDE_POKE
, (LPARAM
)hglobal
, &lo
, &hi
);
2076 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
2077 ok(lo
== 0xcafebabe, "Expected 0xcafebabe, got %08lx\n", lo
);
2078 ok(hi
== 0xdeadbeef, "Expected 0xdeadbeef, got %08lx\n", hi
);
2082 ret
= UnpackDDElParam(WM_DDE_EXECUTE
, 0xcafebabe, &lo
, &hi
);
2083 ok(ret
== TRUE
, "Expected TRUE, got %d\n", ret
);
2084 ok(lo
== 0, "Expected 0, got %08lx\n", lo
);
2085 ok(hi
== 0xcafebabe, "Expected 0xcafebabe, got %08lx\n", hi
);
2092 char buffer
[MAX_PATH
];
2093 STARTUPINFO startup
;
2094 PROCESS_INFORMATION proc
;
2096 argc
= winetest_get_mainargs(&argv
);
2099 if (!lstrcmpA(argv
[2], "ddeml"))
2100 test_ddeml_client();
2101 else if (!lstrcmpA(argv
[2], "msg"))
2107 ZeroMemory(&startup
, sizeof(STARTUPINFO
));
2108 sprintf(buffer
, "%s dde ddeml", argv
[0]);
2109 startup
.cb
= sizeof(startup
);
2110 startup
.dwFlags
= STARTF_USESHOWWINDOW
;
2111 startup
.wShowWindow
= SW_SHOWNORMAL
;
2113 CreateProcessA(NULL
, buffer
, NULL
, NULL
, FALSE
,
2114 CREATE_SUSPENDED
, NULL
, NULL
, &startup
, &proc
);
2116 test_msg_server(proc
.hProcess
, proc
.hThread
);
2118 sprintf(buffer
, "%s dde msg", argv
[0]);
2119 CreateProcessA(NULL
, buffer
, NULL
, NULL
, FALSE
,
2120 0, NULL
, NULL
, &startup
, &proc
);
2122 test_ddeml_server(proc
.hProcess
);
2124 test_dde_aw_transaction();
2126 test_DdeCreateDataHandle();
2127 test_DdeCreateStringHandle();
2128 test_FreeDDElParam();
2129 test_PackDDElParam();
2130 test_UnpackDDElParam();