diff --git a/dlls/user32/tests/dde.c b/dlls/user32/tests/dde.c index b5e05c4..c3997b0 100644 --- a/dlls/user32/tests/dde.c +++ b/dlls/user32/tests/dde.c @@ -2,6 +2,7 @@ * Unit tests for DDE functions * * Copyright (c) 2004 Dmitry Timoshkov + * Copyright (c) 2007 James Hawkins * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -19,14 +20,18 @@ */ #include +#include +#include -#include "wine/test.h" +#include "windef.h" #include "winbase.h" #include "winuser.h" #include "dde.h" #include "ddeml.h" #include "winerror.h" +#include "wine/test.h" + static const WCHAR TEST_DDE_SERVICE[] = {'T','e','s','t','D','D','E','S','e','r','v','i','c','e',0}; static char exec_cmdA[] = "ANSI dde command"; @@ -34,6 +39,202 @@ static WCHAR exec_cmdW[] = {'u','n','i','c','o','d','e',' ','d','d','e',' ','c', static WNDPROC old_dde_client_wndproc; +static void create_dde_window(HWND *hwnd, LPCSTR name, WNDPROC wndproc) +{ + WNDCLASSA wcA; + + memset(&wcA, 0, sizeof(wcA)); + wcA.lpfnWndProc = wndproc; + wcA.lpszClassName = name; + wcA.hInstance = GetModuleHandleA(0); + assert(RegisterClassA(&wcA)); + + *hwnd = CreateWindowExA(0, name, NULL, WS_POPUP, + 500, 500, CW_USEDEFAULT, CW_USEDEFAULT, + GetDesktopWindow(), 0, GetModuleHandleA(0), NULL); + assert(*hwnd); +} + +static LRESULT WINAPI dde_server_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + UINT_PTR lo, hi; + char str[MAX_PATH], *ptr; + HGLOBAL hglobal; + DDEDATA *data; + DDEPOKE *poke; + DWORD size; + + static int msg_index = 0; + static HWND client = 0; + static BOOL executed = FALSE; + + if (msg < WM_DDE_FIRST || msg > WM_DDE_LAST) + return DefWindowProcA(hwnd, msg, wparam, lparam); + + msg_index++; + + switch (msg) + { + case WM_DDE_INITIATE: + { + client = (HWND)wparam; + ok(msg_index == 1, "Expected 1, got %d\n", msg_index); + + GlobalGetAtomNameA(LOWORD(lparam), str, MAX_PATH); + ok(!lstrcmpA(str, "TestDDEService"), "Expected TestDDEService, got %s\n", str); + + GlobalGetAtomNameA(HIWORD(lparam), str, MAX_PATH); + ok(!lstrcmpA(str, "TestDDETopic"), "Expected TestDDETopic, got %s\n", str); + + SendMessageA(client, WM_DDE_ACK, (WPARAM)hwnd, lparam); + + break; + } + + case WM_DDE_REQUEST: + { + ok((msg_index >= 2 && msg_index <= 4) || + (msg_index >= 7 && msg_index <= 8), + "Expected 2, 3, 4, 7 or 8, got %d\n", msg_index); + ok(wparam == (WPARAM)client, "Expected client hwnd, got %08lx\n", wparam); + ok(LOWORD(lparam) == CF_TEXT, "Expected CF_TEXT, got %d\n", LOWORD(lparam)); + + GlobalGetAtomNameA(HIWORD(lparam), str, MAX_PATH); + if (msg_index < 8) + ok(!lstrcmpA(str, "request"), "Expected request, got %s\n", str); + else + ok(!lstrcmpA(str, "executed"), "Expected executed, got %s\n", str); + + if (msg_index == 8) + { + if (executed) + lstrcpyA(str, "command executed\r\n"); + else + lstrcpyA(str, "command not executed\r\n"); + } + else + lstrcpyA(str, "requested data\r\n"); + + size = sizeof(DDEDATA) + lstrlenA(str) + 1; + hglobal = GlobalAlloc(GMEM_MOVEABLE, size); + ok(hglobal != NULL, "Expected non-NULL hglobal\n"); + + data = GlobalLock(hglobal); + ZeroMemory(data, size); + + /* setting fResponse to FALSE at this point destroys + * the internal messaging state of native dde + */ + data->fResponse = TRUE; + + if (msg_index == 2) + data->fRelease = TRUE; + else if (msg_index == 3) + data->fAckReq = TRUE; + + data->cfFormat = CF_TEXT; + lstrcpyA((LPSTR)data->Value, str); + GlobalUnlock(hglobal); + + lparam = PackDDElParam(WM_DDE_ACK, (UINT)hglobal, HIWORD(lparam)); + PostMessageA(client, WM_DDE_DATA, (WPARAM)hwnd, lparam); + + break; + } + + case WM_DDE_POKE: + { + ok(msg_index == 5 || msg_index == 6, "Expected 5 or 6, got %d\n", msg_index); + ok(wparam == (WPARAM)client, "Expected client hwnd, got %08lx\n", wparam); + + UnpackDDElParam(WM_DDE_POKE, lparam, &lo, &hi); + + GlobalGetAtomNameA(hi, str, MAX_PATH); + ok(!lstrcmpA(str, "poker"), "Expected poker, got %s\n", str); + + poke = GlobalLock((HGLOBAL)lo); + ok(poke != NULL, "Expected non-NULL poke\n"); + ok(poke->unused == 0, "Expected 0, got %d\n", poke->unused); + todo_wine + { + ok(poke->fRelease == TRUE, "Expected TRUE, got %d\n", poke->fRelease); + } + ok(poke->fReserved == 0, "Expected 0, got %d\n", poke->fReserved); + ok(poke->cfFormat == CF_TEXT, "Expected CF_TEXT, got %d\n", poke->cfFormat); + + if (msg_index == 5) + ok(lstrcmpA((LPSTR)poke->Value, "poke data\r\n"), + "Expected 'poke data\\r\\n', got %s\n", poke->Value); + else + ok(!lstrcmpA((LPSTR)poke->Value, "poke data\r\n"), + "Expected 'poke data\\r\\n', got %s\n", poke->Value); + + GlobalUnlock((HGLOBAL)lo); + + lparam = PackDDElParam(WM_DDE_ACK, DDE_FACK, hi); + PostMessageA(client, WM_DDE_ACK, (WPARAM)hwnd, lparam); + + break; + } + + case WM_DDE_EXECUTE: + { + ok(msg_index == 7, "Expected 7, got %d\n", msg_index); + ok(wparam == (WPARAM)client, "Expected client hwnd, got %08lx\n", wparam); + + ptr = GlobalLock((HGLOBAL)lparam); + ok(!lstrcmpA(ptr, "[Command(Var)]"), "Expected [Command(Var)], got %s\n", ptr); + GlobalUnlock((HGLOBAL)lparam); + + executed = TRUE; + + lparam = ReuseDDElParam(lparam, WM_DDE_EXECUTE, WM_DDE_ACK, DDE_FACK, HIWORD(lparam)); + PostMessageA(client, WM_DDE_ACK, (WPARAM)hwnd, lparam); + + break; + } + + case WM_DDE_TERMINATE: + { + ok(msg_index == 9, "Expected 9, got %d\n", msg_index); + ok(wparam == (WPARAM)client, "Expected client hwnd, got %08lx\n", wparam); + ok(lparam == 0, "Expected 0, got %08lx\n", lparam); + + PostMessageA(client, WM_DDE_TERMINATE, (WPARAM)hwnd, 0); + + break; + } + + default: + ok(FALSE, "Unhandled msg: %08x\n", msg); + } + + return DefWindowProcA(hwnd, msg, wparam, lparam); +} + +static void test_msg_server(HANDLE hproc) +{ + MSG msg; + HWND hwnd; + + create_dde_window(&hwnd, "dde_server", dde_server_wndproc); + + do + { + while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); + } while (WaitForSingleObject(hproc, 500) == WAIT_TIMEOUT); + + DestroyWindow(hwnd); +} + +static HDDEDATA CALLBACK client_ddeml_callback(UINT uType, UINT uFmt, HCONV hconv, + HSZ hsz1, HSZ hsz2, HDDEDATA hdata, + ULONG_PTR dwData1, ULONG_PTR dwData2) +{ + ok(FALSE, "Unhandled msg: %08x\n", uType); + return 0; +} + static LRESULT WINAPI hook_dde_client_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { UINT_PTR lo, hi; @@ -53,9 +254,9 @@ static LRESULT WINAPI hook_dde_client_wndproc(HWND hwnd, UINT msg, WPARAM wparam return CallWindowProcA(old_dde_client_wndproc, hwnd, msg, wparam, lparam); } -static LRESULT WINAPI dde_server_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) +static LRESULT WINAPI dde_server_wndprocW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { - trace("dde_server_wndproc: %p %04x %08lx %08lx\n", hwnd, msg, wparam, lparam); + trace("dde_server_wndprocW: %p %04x %08lx %08lx\n", hwnd, msg, wparam, lparam); switch (msg) { @@ -159,7 +360,7 @@ static BOOL create_dde_windows(HWND *hwnd_client, HWND *hwnd_server) static const char client_class_name[] = "dde_client_window"; memset(&wcW, 0, sizeof(wcW)); - wcW.lpfnWndProc = dde_server_wndproc; + wcW.lpfnWndProc = dde_server_wndprocW; wcW.lpszClassName = server_class_name; wcW.hInstance = GetModuleHandleA(0); if (!RegisterClassW(&wcW)) return FALSE; @@ -212,7 +413,7 @@ static HDDEDATA CALLBACK client_dde_callback(UINT uType, UINT uFmt, HCONV hconv, return 0; } -static void test_dde_transaction(void) +static void test_dde_aw_transaction(void) { HSZ hsz_server; DWORD dde_inst, ret, err; @@ -296,6 +497,347 @@ todo_wine { DestroyWindow(hwnd_server); } +static void test_ddeml_client(void) +{ + UINT ret; + LPSTR str; + DWORD size, res; + HDDEDATA hdata, op; + HSZ server, topic, item; + DWORD client_pid; + HCONV conversation; + + ret = DdeInitializeA(&client_pid, client_ddeml_callback, APPCMD_CLIENTONLY, 0); + ok(ret == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", ret); + + /* FIXME: make these atoms global and check them in the server */ + + server = DdeCreateStringHandleA(client_pid, "TestDDEService", CP_WINANSI); + topic = DdeCreateStringHandleA(client_pid, "TestDDETopic", CP_WINANSI); + + DdeGetLastError(client_pid); + conversation = DdeConnect(client_pid, server, topic, NULL); + ok(conversation != NULL, "Expected non-NULL conversation\n"); + ret = DdeGetLastError(client_pid); + ok(ret == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", ret); + + DdeFreeStringHandle(client_pid, server); + + item = DdeCreateStringHandleA(client_pid, "request", CP_WINANSI); + + /* XTYP_REQUEST, fRelease = TRUE */ + res = 0xdeadbeef; + DdeGetLastError(client_pid); + hdata = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_REQUEST, 500, &res); + ret = DdeGetLastError(client_pid); + ok(hdata == NULL, "Expected NULL hdata, got %p\n", hdata); + ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %08x\n", res); + ok(ret == DMLERR_DATAACKTIMEOUT, "Expected DMLERR_DATAACKTIMEOUT, got %d\n", ret); + + /* XTYP_REQUEST, fAckReq = TRUE */ + res = 0xdeadbeef; + DdeGetLastError(client_pid); + hdata = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_REQUEST, 500, &res); + ret = DdeGetLastError(client_pid); + ok(hdata != NULL, "Expected non-NULL hdata\n"); + todo_wine + { + ok(res == DDE_FNOTPROCESSED, "Expected DDE_FNOTPROCESSED, got %d\n", res); + ok(ret == DMLERR_MEMORY_ERROR, "Expected DMLERR_MEMORY_ERROR, got %d\n", ret); + } + + str = (LPSTR)DdeAccessData(hdata, &size); + ok(!lstrcmpA(str, "requested data\r\n"), "Expected 'requested data\\r\\n', got %s\n", str); + ok(size == 19, "Expected 19, got %d\n", size); + + ret = DdeUnaccessData(hdata); + ok(ret == TRUE, "Expected TRUE, got %d\n", ret); + + /* XTYP_REQUEST, all params normal */ + res = 0xdeadbeef; + DdeGetLastError(client_pid); + hdata = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_REQUEST, 500, &res); + ret = DdeGetLastError(client_pid); + todo_wine + { + ok(hdata != NULL, "Expected non-NULL hdata\n"); + ok(res == DDE_FNOTPROCESSED, "Expected DDE_FNOTPROCESSED, got %d\n", res); + ok(ret == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", ret); + } + + str = (LPSTR)DdeAccessData(hdata, &size); + todo_wine + { + ok(!lstrcmpA(str, "requested data\r\n"), "Expected 'requested data\\r\\n', got %s\n", str); + } + ok(size == 19, "Expected 19, got %d\n", size); + + ret = DdeUnaccessData(hdata); + ok(ret == TRUE, "Expected TRUE, got %d\n", ret); + + /* XTYP_REQUEST, no item */ + res = 0xdeadbeef; + DdeGetLastError(client_pid); + hdata = DdeClientTransaction(NULL, 0, conversation, 0, CF_TEXT, XTYP_REQUEST, 500, &res); + ret = DdeGetLastError(client_pid); + ok(hdata == NULL, "Expected NULL hdata, got %p\n", hdata); + ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %08x\n", res); + todo_wine + { + ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret); + } + + DdeFreeStringHandle(client_pid, item); + + item = DdeCreateStringHandleA(client_pid, "poker", CP_WINANSI); + + lstrcpyA(str, "poke data\r\n"); + hdata = DdeCreateDataHandle(client_pid, (LPBYTE)str, lstrlenA(str) + 1, + 0, item, CF_TEXT, 0); + ok(hdata != NULL, "Expected non-NULL hdata\n"); + + /* XTYP_POKE, no item */ + res = 0xdeadbeef; + DdeGetLastError(client_pid); + op = DdeClientTransaction((LPBYTE)hdata, -1, conversation, 0, CF_TEXT, XTYP_POKE, 500, &res); + ret = DdeGetLastError(client_pid); + ok(op == NULL, "Expected NULL, got %p\n", op); + ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res); + todo_wine + { + ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret); + } + + /* XTYP_POKE, no data */ + res = 0xdeadbeef; + DdeGetLastError(client_pid); + op = DdeClientTransaction(NULL, 0, conversation, 0, CF_TEXT, XTYP_POKE, 500, &res); + ret = DdeGetLastError(client_pid); + ok(op == NULL, "Expected NULL, got %p\n", op); + ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res); + todo_wine + { + ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret); + } + + /* XTYP_POKE, wrong size */ + res = 0xdeadbeef; + DdeGetLastError(client_pid); + op = DdeClientTransaction((LPBYTE)hdata, 0, conversation, item, CF_TEXT, XTYP_POKE, 500, &res); + ret = DdeGetLastError(client_pid); + todo_wine + { + ok(op == (HDDEDATA)TRUE, "Expected TRUE, got %p\n", op); + ok(res == DDE_FACK, "Expected DDE_FACK, got %d\n", res); + } + ok(ret == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", ret); + + /* XTYP_POKE, correct params */ + res = 0xdeadbeef; + DdeGetLastError(client_pid); + op = DdeClientTransaction((LPBYTE)hdata, -1, conversation, item, CF_TEXT, XTYP_POKE, 500, &res); + ret = DdeGetLastError(client_pid); + todo_wine + { + ok(op == (HDDEDATA)TRUE, "Expected TRUE, got %p\n", op); + ok(res == DDE_FACK, "Expected DDE_FACK, got %d\n", res); + ok(ret == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", ret); + } + + DdeFreeDataHandle(hdata); + + lstrcpyA(str, "[Command(Var)]"); + hdata = DdeCreateDataHandle(client_pid, (LPBYTE)str, lstrlenA(str) + 1, + 0, (HSZ)NULL, CF_TEXT, 0); + ok(hdata != NULL, "Expected non-NULL hdata\n"); + + /* XTYP_EXECUTE, correct params */ + res = 0xdeadbeef; + DdeGetLastError(client_pid); + op = DdeClientTransaction((LPBYTE)hdata, -1, conversation, NULL, 0, XTYP_EXECUTE, 5000, &res); + ret = DdeGetLastError(client_pid); + todo_wine + { + ok(op == (HDDEDATA)TRUE, "Expected TRUE, got %p\n", op); + ok(res == DDE_FACK, "Expected DDE_FACK, got %d\n", res); + ok(ret == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", ret); + } + + /* XTYP_EXECUTE, no data */ + res = 0xdeadbeef; + DdeGetLastError(client_pid); + op = DdeClientTransaction(NULL, 0, conversation, NULL, 0, XTYP_EXECUTE, 5000, &res); + ret = DdeGetLastError(client_pid); + ok(op == NULL, "Expected NULL, got %p\n", op); + ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res); + todo_wine + { + ok(ret == DMLERR_MEMORY_ERROR, "Expected DMLERR_MEMORY_ERROR, got %d\n", ret); + } + + /* XTYP_EXECUTE, no data, -1 size */ + res = 0xdeadbeef; + DdeGetLastError(client_pid); + op = DdeClientTransaction(NULL, -1, conversation, NULL, 0, XTYP_EXECUTE, 5000, &res); + ret = DdeGetLastError(client_pid); + ok(op == NULL, "Expected NULL, got %p\n", op); + ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res); + todo_wine + { + ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret); + } + + DdeFreeStringHandle(client_pid, topic); + DdeFreeDataHandle(hdata); + + item = DdeCreateStringHandleA(client_pid, "executed", CP_WINANSI); + + /* verify the execute */ + res = 0xdeadbeef; + DdeGetLastError(client_pid); + hdata = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_REQUEST, 500, &res); + ret = DdeGetLastError(client_pid); + todo_wine + { + ok(hdata != NULL, "Expected non-NULL hdata\n"); + ok(res == DDE_FNOTPROCESSED, "Expected DDE_FNOTPROCESSED, got %d\n", res); + ok(ret == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", ret); + } + + str = (LPSTR)DdeAccessData(hdata, &size); + todo_wine + { + ok(!lstrcmpA(str, "command executed\r\n"), "Expected 'command executed\\r\\n', got %s\n", str); + ok(size == 21, "Expected 21, got %d\n", size); + } + + ret = DdeUnaccessData(hdata); + ok(ret == TRUE, "Expected TRUE, got %d\n", ret); + + /* invalid transactions */ + + res = 0xdeadbeef; + DdeGetLastError(client_pid); + op = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_ADVREQ, 500, &res); + ret = DdeGetLastError(client_pid); + ok(op == NULL, "Expected NULL, got %p\n", op); + ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res); + todo_wine + { + ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret); + } + + res = 0xdeadbeef; + DdeGetLastError(client_pid); + op = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_CONNECT, 500, &res); + ret = DdeGetLastError(client_pid); + ok(op == NULL, "Expected NULL, got %p\n", op); + ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res); + todo_wine + { + ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret); + } + + res = 0xdeadbeef; + DdeGetLastError(client_pid); + op = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_CONNECT_CONFIRM, 500, &res); + ret = DdeGetLastError(client_pid); + ok(op == NULL, "Expected NULL, got %p\n", op); + ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res); + todo_wine + { + ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret); + } + + res = 0xdeadbeef; + DdeGetLastError(client_pid); + op = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_DISCONNECT, 500, &res); + ret = DdeGetLastError(client_pid); + ok(op == NULL, "Expected NULL, got %p\n", op); + ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res); + todo_wine + { + ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret); + } + + res = 0xdeadbeef; + DdeGetLastError(client_pid); + op = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_ERROR, 500, &res); + ret = DdeGetLastError(client_pid); + ok(op == NULL, "Expected NULL, got %p\n", op); + ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res); + todo_wine + { + ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret); + } + + res = 0xdeadbeef; + DdeGetLastError(client_pid); + op = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_MONITOR, 500, &res); + ret = DdeGetLastError(client_pid); + ok(op == NULL, "Expected NULL, got %p\n", op); + ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res); + todo_wine + { + ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret); + } + + res = 0xdeadbeef; + DdeGetLastError(client_pid); + op = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_REGISTER, 500, &res); + ret = DdeGetLastError(client_pid); + ok(op == NULL, "Expected NULL, got %p\n", op); + ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res); + todo_wine + { + ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret); + } + + res = 0xdeadbeef; + DdeGetLastError(client_pid); + op = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_UNREGISTER, 500, &res); + ret = DdeGetLastError(client_pid); + ok(op == NULL, "Expected NULL, got %p\n", op); + ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res); + todo_wine + { + ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret); + } + + res = 0xdeadbeef; + DdeGetLastError(client_pid); + op = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_WILDCONNECT, 500, &res); + ret = DdeGetLastError(client_pid); + ok(op == NULL, "Expected NULL, got %p\n", op); + ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res); + todo_wine + { + ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret); + } + + res = 0xdeadbeef; + DdeGetLastError(client_pid); + op = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_XACT_COMPLETE, 500, &res); + ret = DdeGetLastError(client_pid); + ok(op == NULL, "Expected NULL, got %p\n", op); + ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res); + todo_wine + { + ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret); + } + + DdeFreeStringHandle(client_pid, item); + + ret = DdeDisconnect(conversation); + todo_wine + { + ok(ret == TRUE, "Expected TRUE, got %d\n", ret); + } + + ret = DdeUninitialize(client_pid); + ok(ret == TRUE, "Expected TRUE, got %d\n", ret); +} + static void test_DdeCreateStringHandleW(DWORD dde_inst, int codepage) { static const WCHAR dde_string[] = {'D','D','E',' ','S','t','r','i','n','g',0}; @@ -383,7 +925,7 @@ static void test_DdeCreateStringHandle(void) dde_inst = 0xdeadbeef; SetLastError(0xdeadbeef); - ret = DdeInitializeW(&dde_inst, client_dde_callback, APPCMD_CLIENTONLY, 0); + ret = DdeInitializeW(&dde_inst, client_ddeml_callback, APPCMD_CLIENTONLY, 0); if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) { trace("Skipping the DDE test on a Win9x platform\n"); @@ -394,7 +936,7 @@ static void test_DdeCreateStringHandle(void) ok(DdeGetLastError(dde_inst) == DMLERR_INVALIDPARAMETER, "expected DMLERR_INVALIDPARAMETER\n"); dde_inst = 0; - ret = DdeInitializeW(&dde_inst, client_dde_callback, APPCMD_CLIENTONLY, 0); + ret = DdeInitializeW(&dde_inst, client_ddeml_callback, APPCMD_CLIENTONLY, 0); ok(ret == DMLERR_NO_ERROR, "DdeInitializeW failed with error %04x (%08x)\n", ret, DdeGetLastError(dde_inst)); @@ -787,7 +1329,34 @@ static void test_UnpackDDElParam(void) START_TEST(dde) { - test_dde_transaction(); + int argc; + char **argv; + char buffer[MAX_PATH]; + STARTUPINFO startup; + PROCESS_INFORMATION proc; + + argc = winetest_get_mainargs(&argv); + if (argc == 3) + { + if (!lstrcmpA(argv[2], "ddeml")) + test_ddeml_client(); + + return; + } + + ZeroMemory(&startup, sizeof(STARTUPINFO)); + sprintf(buffer, "%s dde ddeml", argv[0]); + startup.cb = sizeof(startup); + startup.dwFlags = STARTF_USESHOWWINDOW; + startup.wShowWindow = SW_SHOWNORMAL; + + CreateProcessA(NULL, buffer, NULL, NULL, FALSE, + 0, NULL, NULL, &startup, &proc); + + test_msg_server(proc.hProcess); + + test_dde_aw_transaction(); + test_DdeCreateStringHandle(); test_FreeDDElParam(); test_PackDDElParam(); diff --git a/include/ddeml.h b/include/ddeml.h index 8fa67df..400ce5b 100644 --- a/include/ddeml.h +++ b/include/ddeml.h @@ -192,6 +192,7 @@ extern "C" { #define XTYP_DISCONNECT (0x00C0 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK ) #define XTYP_UNREGISTER (0x00D0 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK ) #define XTYP_WILDCONNECT (0x00E0 | XCLASS_DATA | XTYPF_NOBLOCK) +#define XTYP_MONITOR (0x00F0 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK) #define XTYP_MASK 0x00F0 #define XTYP_SHIFT 4 -- 1.4.4.2