2004-04-23 23:32:17 +02:00
|
|
|
/*
|
|
|
|
* Unit tests for DDE functions
|
|
|
|
*
|
|
|
|
* Copyright (c) 2004 Dmitry Timoshkov
|
2007-10-04 07:28:45 +02:00
|
|
|
* Copyright (c) 2007 James Hawkins
|
2004-04-23 23:32:17 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-04-23 23:32:17 +02:00
|
|
|
*/
|
|
|
|
|
2007-10-04 07:28:45 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
2004-04-23 23:32:17 +02:00
|
|
|
|
2007-10-04 07:28:45 +02:00
|
|
|
#include "windef.h"
|
2004-04-23 23:32:17 +02:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
2010-06-24 19:56:49 +02:00
|
|
|
#include "winnls.h"
|
2005-07-08 13:33:09 +02:00
|
|
|
#include "dde.h"
|
2004-04-23 23:32:17 +02:00
|
|
|
#include "ddeml.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
|
2007-10-04 07:28:45 +02:00
|
|
|
#include "wine/test.h"
|
|
|
|
|
2005-07-08 13:33:09 +02:00
|
|
|
static const WCHAR TEST_DDE_SERVICE[] = {'T','e','s','t','D','D','E','S','e','r','v','i','c','e',0};
|
|
|
|
|
2006-10-04 23:45:14 +02:00
|
|
|
static char exec_cmdA[] = "ANSI dde command";
|
2010-06-23 14:19:51 +02:00
|
|
|
static WCHAR exec_cmdAW[] = {'A','N','S','I',' ','d','d','e',' ','c','o','m','m','a','n','d',0};
|
2006-10-04 23:45:14 +02:00
|
|
|
static WCHAR exec_cmdW[] = {'u','n','i','c','o','d','e',' ','d','d','e',' ','c','o','m','m','a','n','d',0};
|
2010-06-23 14:19:51 +02:00
|
|
|
static char exec_cmdWA[] = "unicode dde command";
|
2005-07-08 13:33:09 +02:00
|
|
|
|
|
|
|
static WNDPROC old_dde_client_wndproc;
|
|
|
|
|
2007-10-15 21:19:22 +02:00
|
|
|
static const DWORD default_timeout = 200;
|
|
|
|
|
2007-10-08 11:06:45 +02:00
|
|
|
static void flush_events(void)
|
|
|
|
{
|
|
|
|
MSG msg;
|
2007-10-15 21:19:22 +02:00
|
|
|
int diff = default_timeout;
|
2008-03-05 16:48:04 +01:00
|
|
|
int min_timeout = 50;
|
2007-10-08 11:06:45 +02:00
|
|
|
DWORD time = GetTickCount() + diff;
|
|
|
|
|
|
|
|
while (diff > 0)
|
|
|
|
{
|
2008-03-05 16:48:04 +01:00
|
|
|
if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break;
|
2007-10-08 11:06:45 +02:00
|
|
|
while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
|
|
|
|
diff = time - GetTickCount();
|
2008-03-05 16:48:04 +01:00
|
|
|
min_timeout = 10;
|
2007-10-08 11:06:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-04 07:28:45 +02:00
|
|
|
static void create_dde_window(HWND *hwnd, LPCSTR name, WNDPROC wndproc)
|
|
|
|
{
|
|
|
|
WNDCLASSA wcA;
|
2011-02-24 17:53:16 +01:00
|
|
|
ATOM aclass;
|
2007-10-04 07:28:45 +02:00
|
|
|
|
|
|
|
memset(&wcA, 0, sizeof(wcA));
|
|
|
|
wcA.lpfnWndProc = wndproc;
|
|
|
|
wcA.lpszClassName = name;
|
|
|
|
wcA.hInstance = GetModuleHandleA(0);
|
2011-02-24 17:53:16 +01:00
|
|
|
aclass = RegisterClassA(&wcA);
|
|
|
|
ok (aclass, "RegisterClass failed\n");
|
2007-10-04 07:28:45 +02:00
|
|
|
|
|
|
|
*hwnd = CreateWindowExA(0, name, NULL, WS_POPUP,
|
|
|
|
500, 500, CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
GetDesktopWindow(), 0, GetModuleHandleA(0), NULL);
|
2011-02-24 17:53:16 +01:00
|
|
|
ok(*hwnd != NULL, "CreateWindowExA failed\n");
|
2007-10-04 07:28:45 +02:00
|
|
|
}
|
|
|
|
|
2008-09-02 12:46:51 +02:00
|
|
|
static void destroy_dde_window(HWND *hwnd, LPCSTR name)
|
|
|
|
{
|
|
|
|
DestroyWindow(*hwnd);
|
|
|
|
UnregisterClass(name, GetModuleHandleA(0));
|
|
|
|
}
|
|
|
|
|
2007-10-04 07:28:45 +02:00
|
|
|
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);
|
|
|
|
|
2010-06-23 15:22:29 +02:00
|
|
|
lparam = PackDDElParam(WM_DDE_DATA, (UINT_PTR)hglobal, HIWORD(lparam));
|
2007-10-04 07:28:45 +02:00
|
|
|
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");
|
2007-10-12 07:11:56 +02:00
|
|
|
ok(poke->fReserved == 0, "Expected 0, got %d\n", poke->fReserved);
|
2007-10-12 07:25:32 +02:00
|
|
|
ok(poke->unused == 0, "Expected 0, got %d\n", poke->unused);
|
|
|
|
ok(poke->fRelease == TRUE, "Expected TRUE, got %d\n", poke->fRelease);
|
|
|
|
ok(poke->cfFormat == CF_TEXT, "Expected CF_TEXT, got %d\n", poke->cfFormat);
|
2007-10-04 07:28:45 +02:00
|
|
|
|
|
|
|
if (msg_index == 5)
|
2008-07-17 16:10:28 +02:00
|
|
|
{
|
|
|
|
size = GlobalSize((HGLOBAL)lo);
|
2010-06-23 15:22:29 +02:00
|
|
|
ok(size == 4 || broken(size == 32), /* sizes are rounded up on win9x */ "got %d\n", size);
|
2008-07-17 16:10:28 +02:00
|
|
|
}
|
2007-10-12 07:15:27 +02:00
|
|
|
else
|
2007-10-04 07:28:45 +02:00
|
|
|
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:
|
|
|
|
{
|
2007-10-12 07:15:27 +02:00
|
|
|
ok(msg_index == 7, "Expected 7, got %d\n", msg_index);
|
2007-10-04 07:28:45 +02:00
|
|
|
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;
|
|
|
|
|
2009-10-19 16:21:50 +02:00
|
|
|
lparam = ReuseDDElParam(lparam, WM_DDE_EXECUTE, WM_DDE_ACK, DDE_FACK, lparam);
|
2007-10-04 07:28:45 +02:00
|
|
|
PostMessageA(client, WM_DDE_ACK, (WPARAM)hwnd, lparam);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_DDE_TERMINATE:
|
|
|
|
{
|
2007-10-12 07:15:27 +02:00
|
|
|
ok(msg_index == 9, "Expected 9, got %d\n", msg_index);
|
2007-10-04 07:28:45 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2010-06-23 15:22:29 +02:00
|
|
|
case WM_DDE_ACK: /* happens on win9x when fAckReq is TRUE, ignore it */
|
|
|
|
ok(msg_index == 4, "Expected 4, got %d\n", msg_index);
|
|
|
|
msg_index--;
|
|
|
|
break;
|
|
|
|
|
2007-10-04 07:28:45 +02:00
|
|
|
default:
|
2007-10-12 07:15:27 +02:00
|
|
|
ok(FALSE, "Unhandled msg: %08x\n", msg);
|
2007-10-04 07:28:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return DefWindowProcA(hwnd, msg, wparam, lparam);
|
|
|
|
}
|
|
|
|
|
2008-06-02 14:13:01 +02:00
|
|
|
static void test_msg_server(HANDLE hproc, HANDLE hthread)
|
2007-10-04 07:28:45 +02:00
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
HWND hwnd;
|
2007-10-15 21:19:22 +02:00
|
|
|
DWORD res;
|
2007-10-04 07:28:45 +02:00
|
|
|
|
|
|
|
create_dde_window(&hwnd, "dde_server", dde_server_wndproc);
|
2008-06-05 12:43:17 +02:00
|
|
|
ResumeThread( hthread );
|
2007-10-04 07:28:45 +02:00
|
|
|
|
2007-10-15 21:19:22 +02:00
|
|
|
while (MsgWaitForMultipleObjects( 1, &hproc, FALSE, INFINITE, QS_ALLINPUT ) != 0)
|
2007-10-04 07:28:45 +02:00
|
|
|
{
|
|
|
|
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
|
2007-10-15 21:19:22 +02:00
|
|
|
}
|
2007-10-04 07:28:45 +02:00
|
|
|
|
2008-09-02 12:46:51 +02:00
|
|
|
destroy_dde_window(&hwnd, "dde_server");
|
2007-10-15 21:19:22 +02:00
|
|
|
GetExitCodeProcess( hproc, &res );
|
|
|
|
ok( !res, "client failed with %u error(s)\n", res );
|
2007-10-04 07:28:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
static void test_ddeml_client(void)
|
2005-07-08 13:33:09 +02:00
|
|
|
{
|
2007-10-08 11:06:08 +02:00
|
|
|
UINT ret;
|
2007-11-09 13:14:37 +01:00
|
|
|
char buffer[32];
|
2007-10-08 11:06:08 +02:00
|
|
|
LPSTR str;
|
|
|
|
DWORD size, res;
|
|
|
|
HDDEDATA hdata, op;
|
|
|
|
HSZ server, topic, item;
|
|
|
|
DWORD client_pid;
|
|
|
|
HCONV conversation;
|
2005-07-08 13:33:09 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
client_pid = 0;
|
|
|
|
ret = DdeInitializeA(&client_pid, client_ddeml_callback, APPCMD_CLIENTONLY, 0);
|
|
|
|
ok(ret == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", ret);
|
2005-07-08 13:33:09 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
/* FIXME: make these atoms global and check them in the server */
|
2005-07-08 13:33:09 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
server = DdeCreateStringHandleA(client_pid, "TestDDEService", CP_WINANSI);
|
|
|
|
topic = DdeCreateStringHandleA(client_pid, "TestDDETopic", CP_WINANSI);
|
2005-07-08 13:33:09 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
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);
|
2005-07-08 13:33:09 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
DdeFreeStringHandle(client_pid, server);
|
2005-07-08 13:33:09 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
item = DdeCreateStringHandleA(client_pid, "request", CP_WINANSI);
|
2005-07-08 13:33:09 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
/* XTYP_REQUEST, fRelease = TRUE */
|
|
|
|
res = 0xdeadbeef;
|
|
|
|
DdeGetLastError(client_pid);
|
2007-10-15 21:19:22 +02:00
|
|
|
hdata = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_REQUEST, default_timeout, &res);
|
2007-10-08 11:06:08 +02:00
|
|
|
ret = DdeGetLastError(client_pid);
|
2008-08-08 13:38:15 +02:00
|
|
|
ok(ret == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", ret);
|
2010-06-23 15:22:29 +02:00
|
|
|
ok(res == DDE_FNOTPROCESSED || broken(res == 0xdeadbeef), /* win9x */
|
|
|
|
"Expected DDE_FNOTPROCESSED, got %08x\n", res);
|
|
|
|
ok( hdata != NULL, "hdata is NULL\n" );
|
|
|
|
if (hdata)
|
2007-11-09 12:42:32 +01:00
|
|
|
{
|
|
|
|
str = (LPSTR)DdeAccessData(hdata, &size);
|
|
|
|
ok(!lstrcmpA(str, "requested data\r\n"), "Expected 'requested data\\r\\n', got %s\n", str);
|
2010-06-23 15:22:29 +02:00
|
|
|
ok(size == 19 || broken(size == 28), /* sizes are rounded up on win9x */
|
|
|
|
"Expected 19, got %d\n", size);
|
2005-07-08 13:33:09 +02:00
|
|
|
|
2007-11-09 12:42:32 +01:00
|
|
|
ret = DdeUnaccessData(hdata);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
}
|
2007-10-25 22:25:27 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
/* XTYP_REQUEST, fAckReq = TRUE */
|
|
|
|
res = 0xdeadbeef;
|
|
|
|
DdeGetLastError(client_pid);
|
2007-10-15 21:19:22 +02:00
|
|
|
hdata = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_REQUEST, default_timeout, &res);
|
2007-10-08 11:06:08 +02:00
|
|
|
ret = DdeGetLastError(client_pid);
|
2010-06-23 15:22:29 +02:00
|
|
|
ok(res == DDE_FNOTPROCESSED || broken(res == 0xdeadbeef), /* win9x */
|
|
|
|
"Expected DDE_FNOTPROCESSED, got %x\n", res);
|
2008-08-08 13:38:15 +02:00
|
|
|
todo_wine
|
2010-06-23 15:22:29 +02:00
|
|
|
ok(ret == DMLERR_MEMORY_ERROR || broken(ret == 0), /* win9x */
|
|
|
|
"Expected DMLERR_MEMORY_ERROR, got %d\n", ret);
|
|
|
|
ok( hdata != NULL, "hdata is NULL\n" );
|
|
|
|
if (hdata)
|
2007-11-09 12:42:32 +01:00
|
|
|
{
|
|
|
|
str = (LPSTR)DdeAccessData(hdata, &size);
|
|
|
|
ok(!lstrcmpA(str, "requested data\r\n"), "Expected 'requested data\\r\\n', got %s\n", str);
|
2010-06-23 15:22:29 +02:00
|
|
|
ok(size == 19 || broken(size == 28), /* sizes are rounded up on win9x */
|
|
|
|
"Expected 19, got %d\n", size);
|
2005-07-08 13:33:09 +02:00
|
|
|
|
2007-11-09 12:42:32 +01:00
|
|
|
ret = DdeUnaccessData(hdata);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
}
|
2005-07-08 13:33:09 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
/* XTYP_REQUEST, all params normal */
|
|
|
|
res = 0xdeadbeef;
|
|
|
|
DdeGetLastError(client_pid);
|
2007-10-15 21:19:22 +02:00
|
|
|
hdata = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_REQUEST, default_timeout, &res);
|
2007-10-08 11:06:08 +02:00
|
|
|
ret = DdeGetLastError(client_pid);
|
2007-10-12 07:11:56 +02:00
|
|
|
ok(ret == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", ret);
|
2010-06-23 15:22:29 +02:00
|
|
|
ok(res == DDE_FNOTPROCESSED || broken(res == 0xdeadbeef), /* win9x */
|
|
|
|
"Expected DDE_FNOTPROCESSED, got %x\n", res);
|
2007-11-09 12:42:32 +01:00
|
|
|
if (hdata == NULL)
|
|
|
|
ok(FALSE, "hdata is NULL\n");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
str = (LPSTR)DdeAccessData(hdata, &size);
|
|
|
|
ok(!lstrcmpA(str, "requested data\r\n"), "Expected 'requested data\\r\\n', got %s\n", str);
|
2010-06-23 15:22:29 +02:00
|
|
|
ok(size == 19 || broken(size == 28), /* sizes are rounded up on win9x */
|
|
|
|
"Expected 19, got %d\n", size);
|
2005-07-08 13:33:09 +02:00
|
|
|
|
2007-11-09 12:42:32 +01:00
|
|
|
ret = DdeUnaccessData(hdata);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
}
|
2005-07-08 13:33:09 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
/* XTYP_REQUEST, no item */
|
|
|
|
res = 0xdeadbeef;
|
|
|
|
DdeGetLastError(client_pid);
|
2007-10-15 21:19:22 +02:00
|
|
|
hdata = DdeClientTransaction(NULL, 0, conversation, 0, CF_TEXT, XTYP_REQUEST, default_timeout, &res);
|
2007-10-08 11:06:08 +02:00
|
|
|
ret = DdeGetLastError(client_pid);
|
|
|
|
ok(hdata == NULL, "Expected NULL hdata, got %p\n", hdata);
|
|
|
|
ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %08x\n", res);
|
2007-10-12 07:14:34 +02:00
|
|
|
ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret);
|
2005-07-08 13:33:09 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
DdeFreeStringHandle(client_pid, item);
|
2005-07-08 13:33:09 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
item = DdeCreateStringHandleA(client_pid, "poker", CP_WINANSI);
|
|
|
|
|
2007-11-09 13:14:37 +01:00
|
|
|
lstrcpyA(buffer, "poke data\r\n");
|
|
|
|
hdata = DdeCreateDataHandle(client_pid, (LPBYTE)buffer, lstrlenA(buffer) + 1,
|
2007-10-08 11:06:08 +02:00
|
|
|
0, item, CF_TEXT, 0);
|
|
|
|
ok(hdata != NULL, "Expected non-NULL hdata\n");
|
|
|
|
|
|
|
|
/* XTYP_POKE, no item */
|
|
|
|
res = 0xdeadbeef;
|
|
|
|
DdeGetLastError(client_pid);
|
2007-10-15 21:19:22 +02:00
|
|
|
op = DdeClientTransaction((LPBYTE)hdata, -1, conversation, 0, CF_TEXT, XTYP_POKE, default_timeout, &res);
|
2007-10-08 11:06:08 +02:00
|
|
|
ret = DdeGetLastError(client_pid);
|
|
|
|
ok(op == NULL, "Expected NULL, got %p\n", op);
|
|
|
|
ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res);
|
2007-10-12 07:20:08 +02:00
|
|
|
ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret);
|
2005-07-08 13:33:09 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
/* XTYP_POKE, no data */
|
|
|
|
res = 0xdeadbeef;
|
|
|
|
DdeGetLastError(client_pid);
|
2007-10-15 21:19:22 +02:00
|
|
|
op = DdeClientTransaction(NULL, 0, conversation, 0, CF_TEXT, XTYP_POKE, default_timeout, &res);
|
2007-10-08 11:06:08 +02:00
|
|
|
ret = DdeGetLastError(client_pid);
|
|
|
|
ok(op == NULL, "Expected NULL, got %p\n", op);
|
|
|
|
ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res);
|
2007-10-12 07:20:08 +02:00
|
|
|
ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret);
|
2005-07-08 13:33:09 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
/* XTYP_POKE, wrong size */
|
|
|
|
res = 0xdeadbeef;
|
|
|
|
DdeGetLastError(client_pid);
|
2007-10-15 21:19:22 +02:00
|
|
|
op = DdeClientTransaction((LPBYTE)hdata, 0, conversation, item, CF_TEXT, XTYP_POKE, default_timeout, &res);
|
2007-10-08 11:06:08 +02:00
|
|
|
ret = DdeGetLastError(client_pid);
|
2007-10-12 07:11:56 +02:00
|
|
|
ok(op == (HDDEDATA)TRUE, "Expected TRUE, got %p\n", op);
|
2010-06-24 23:36:24 +02:00
|
|
|
ok(res == DDE_FACK || broken(res == (0xdead0000 | DDE_FACK)), /* win9x */
|
|
|
|
"Expected DDE_FACK, got %x\n", res);
|
2007-10-08 11:06:08 +02:00
|
|
|
ok(ret == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", ret);
|
2005-07-08 13:33:09 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
/* XTYP_POKE, correct params */
|
|
|
|
res = 0xdeadbeef;
|
|
|
|
DdeGetLastError(client_pid);
|
2007-10-15 21:19:22 +02:00
|
|
|
op = DdeClientTransaction((LPBYTE)hdata, -1, conversation, item, CF_TEXT, XTYP_POKE, default_timeout, &res);
|
2007-10-08 11:06:08 +02:00
|
|
|
ret = DdeGetLastError(client_pid);
|
2007-10-12 07:11:56 +02:00
|
|
|
ok(op == (HDDEDATA)TRUE, "Expected TRUE, got %p\n", op);
|
2010-06-23 15:22:29 +02:00
|
|
|
ok(res == DDE_FACK || broken(res == (0xdead0000 | DDE_FACK)), /* win9x */
|
|
|
|
"Expected DDE_FACK, got %x\n", res);
|
2007-10-12 07:11:56 +02:00
|
|
|
ok(ret == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", ret);
|
2005-07-08 13:33:09 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
DdeFreeDataHandle(hdata);
|
2005-07-08 13:33:09 +02:00
|
|
|
|
2007-11-09 13:14:37 +01:00
|
|
|
lstrcpyA(buffer, "[Command(Var)]");
|
|
|
|
hdata = DdeCreateDataHandle(client_pid, (LPBYTE)buffer, lstrlenA(buffer) + 1,
|
2007-10-08 11:06:08 +02:00
|
|
|
0, NULL, CF_TEXT, 0);
|
|
|
|
ok(hdata != NULL, "Expected non-NULL hdata\n");
|
2005-07-08 13:33:09 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
/* XTYP_EXECUTE, correct params */
|
|
|
|
res = 0xdeadbeef;
|
|
|
|
DdeGetLastError(client_pid);
|
2007-10-15 21:19:22 +02:00
|
|
|
op = DdeClientTransaction((LPBYTE)hdata, -1, conversation, NULL, 0, XTYP_EXECUTE, default_timeout, &res);
|
2007-10-08 11:06:08 +02:00
|
|
|
ret = DdeGetLastError(client_pid);
|
2007-10-12 07:11:56 +02:00
|
|
|
ok(ret == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", ret);
|
2007-11-09 15:45:51 +01:00
|
|
|
ok(op == (HDDEDATA)TRUE, "Expected TRUE, got %p\n", op);
|
2010-06-24 23:36:24 +02:00
|
|
|
ok(res == DDE_FACK || broken(res == (0xdead0000 | DDE_FACK)), /* win9x */
|
|
|
|
"Expected DDE_FACK, got %x\n", res);
|
2005-07-08 13:33:09 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
/* XTYP_EXECUTE, no data */
|
|
|
|
res = 0xdeadbeef;
|
|
|
|
DdeGetLastError(client_pid);
|
2007-10-15 21:19:22 +02:00
|
|
|
op = DdeClientTransaction(NULL, 0, conversation, NULL, 0, XTYP_EXECUTE, default_timeout, &res);
|
2007-10-08 11:06:08 +02:00
|
|
|
ret = DdeGetLastError(client_pid);
|
2010-06-24 23:36:24 +02:00
|
|
|
ok(op == NULL || broken(op == (HDDEDATA)TRUE), /* win9x */ "Expected NULL, got %p\n", op);
|
|
|
|
if (!op)
|
|
|
|
{
|
|
|
|
ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res);
|
|
|
|
ok(ret == DMLERR_MEMORY_ERROR, "Expected DMLERR_MEMORY_ERROR, got %d\n", ret);
|
|
|
|
}
|
|
|
|
else /* win9x */
|
|
|
|
{
|
|
|
|
ok(res == (0xdead0000 | DDE_FACK), "Expected DDE_FACK, got %x\n", res);
|
|
|
|
ok(ret == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", ret);
|
|
|
|
}
|
2005-07-08 13:33:09 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
/* XTYP_EXECUTE, no data, -1 size */
|
|
|
|
res = 0xdeadbeef;
|
|
|
|
DdeGetLastError(client_pid);
|
2007-10-15 21:19:22 +02:00
|
|
|
op = DdeClientTransaction(NULL, -1, conversation, NULL, 0, XTYP_EXECUTE, default_timeout, &res);
|
2007-10-08 11:06:08 +02:00
|
|
|
ret = DdeGetLastError(client_pid);
|
|
|
|
ok(op == NULL, "Expected NULL, got %p\n", op);
|
|
|
|
ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res);
|
2010-06-24 23:36:24 +02:00
|
|
|
ok(ret == DMLERR_INVALIDPARAMETER || broken(ret == DMLERR_NO_ERROR), /* win9x */
|
|
|
|
"Expected DMLERR_INVALIDPARAMETER, got %d\n", ret);
|
2005-07-08 13:33:09 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
DdeFreeStringHandle(client_pid, topic);
|
|
|
|
DdeFreeDataHandle(hdata);
|
2005-07-08 13:33:09 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
item = DdeCreateStringHandleA(client_pid, "executed", CP_WINANSI);
|
2005-07-08 13:33:09 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
/* verify the execute */
|
2007-10-04 07:28:45 +02:00
|
|
|
res = 0xdeadbeef;
|
|
|
|
DdeGetLastError(client_pid);
|
2007-10-15 21:19:22 +02:00
|
|
|
hdata = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_REQUEST, default_timeout, &res);
|
2007-10-04 07:28:45 +02:00
|
|
|
ret = DdeGetLastError(client_pid);
|
2007-10-12 07:11:56 +02:00
|
|
|
ok(ret == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", ret);
|
2010-06-24 23:36:24 +02:00
|
|
|
ok(res == DDE_FNOTPROCESSED || broken(res == (0xdead0000 | DDE_FNOTPROCESSED)), /* win9x */
|
|
|
|
"Expected DDE_FNOTPROCESSED, got %d\n", res);
|
2007-11-09 12:42:32 +01:00
|
|
|
if (hdata == NULL)
|
|
|
|
ok(FALSE, "hdata is NULL\n");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
str = (LPSTR)DdeAccessData(hdata, &size);
|
|
|
|
ok(!lstrcmpA(str, "command executed\r\n"), "Expected 'command executed\\r\\n', got %s\n", str);
|
2010-06-24 23:36:24 +02:00
|
|
|
ok(size == 21 || broken(size == 28), /* sizes are rounded up on win9x */
|
|
|
|
"Expected 21, got %d\n", size);
|
2007-10-04 07:28:45 +02:00
|
|
|
|
2007-11-09 12:42:32 +01:00
|
|
|
ret = DdeUnaccessData(hdata);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
}
|
2007-10-04 07:28:45 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
/* invalid transactions */
|
2007-10-04 07:28:45 +02:00
|
|
|
res = 0xdeadbeef;
|
|
|
|
DdeGetLastError(client_pid);
|
2007-10-15 21:19:22 +02:00
|
|
|
op = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_ADVREQ, default_timeout, &res);
|
2007-10-04 07:28:45 +02:00
|
|
|
ret = DdeGetLastError(client_pid);
|
2007-10-08 11:06:08 +02:00
|
|
|
ok(op == NULL, "Expected NULL, got %p\n", op);
|
|
|
|
ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res);
|
2007-10-12 07:11:56 +02:00
|
|
|
ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret);
|
2007-10-04 07:28:45 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
res = 0xdeadbeef;
|
|
|
|
DdeGetLastError(client_pid);
|
2007-10-15 21:19:22 +02:00
|
|
|
op = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_CONNECT, default_timeout, &res);
|
2007-10-08 11:06:08 +02:00
|
|
|
ret = DdeGetLastError(client_pid);
|
|
|
|
ok(op == NULL, "Expected NULL, got %p\n", op);
|
|
|
|
ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res);
|
2007-10-12 07:11:56 +02:00
|
|
|
ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret);
|
2007-10-04 07:28:45 +02:00
|
|
|
|
|
|
|
res = 0xdeadbeef;
|
|
|
|
DdeGetLastError(client_pid);
|
2007-10-15 21:19:22 +02:00
|
|
|
op = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_CONNECT_CONFIRM, default_timeout, &res);
|
2007-10-04 07:28:45 +02:00
|
|
|
ret = DdeGetLastError(client_pid);
|
2007-10-08 11:06:08 +02:00
|
|
|
ok(op == NULL, "Expected NULL, got %p\n", op);
|
|
|
|
ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res);
|
2007-10-12 07:11:56 +02:00
|
|
|
ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret);
|
2007-10-04 07:28:45 +02:00
|
|
|
|
|
|
|
res = 0xdeadbeef;
|
|
|
|
DdeGetLastError(client_pid);
|
2007-10-15 21:19:22 +02:00
|
|
|
op = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_DISCONNECT, default_timeout, &res);
|
2007-10-04 07:28:45 +02:00
|
|
|
ret = DdeGetLastError(client_pid);
|
|
|
|
ok(op == NULL, "Expected NULL, got %p\n", op);
|
|
|
|
ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res);
|
2007-10-12 07:11:56 +02:00
|
|
|
ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret);
|
2007-10-04 07:28:45 +02:00
|
|
|
|
|
|
|
res = 0xdeadbeef;
|
|
|
|
DdeGetLastError(client_pid);
|
2007-10-15 21:19:22 +02:00
|
|
|
op = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_ERROR, default_timeout, &res);
|
2007-10-04 07:28:45 +02:00
|
|
|
ret = DdeGetLastError(client_pid);
|
|
|
|
ok(op == NULL, "Expected NULL, got %p\n", op);
|
|
|
|
ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res);
|
2007-10-12 07:11:56 +02:00
|
|
|
ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret);
|
2007-10-04 07:28:45 +02:00
|
|
|
|
|
|
|
res = 0xdeadbeef;
|
|
|
|
DdeGetLastError(client_pid);
|
2007-10-15 21:19:22 +02:00
|
|
|
op = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_MONITOR, default_timeout, &res);
|
2007-10-04 07:28:45 +02:00
|
|
|
ret = DdeGetLastError(client_pid);
|
2007-10-08 11:06:08 +02:00
|
|
|
ok(op == NULL, "Expected NULL, got %p\n", op);
|
|
|
|
ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res);
|
2007-10-12 07:11:56 +02:00
|
|
|
ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret);
|
2007-10-04 07:28:45 +02:00
|
|
|
|
|
|
|
res = 0xdeadbeef;
|
|
|
|
DdeGetLastError(client_pid);
|
2007-10-15 21:19:22 +02:00
|
|
|
op = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_REGISTER, default_timeout, &res);
|
2007-10-04 07:28:45 +02:00
|
|
|
ret = DdeGetLastError(client_pid);
|
2007-10-08 11:06:08 +02:00
|
|
|
ok(op == NULL, "Expected NULL, got %p\n", op);
|
|
|
|
ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res);
|
2007-10-12 07:11:56 +02:00
|
|
|
ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret);
|
2007-10-04 07:28:45 +02:00
|
|
|
|
|
|
|
res = 0xdeadbeef;
|
|
|
|
DdeGetLastError(client_pid);
|
2007-10-15 21:19:22 +02:00
|
|
|
op = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_UNREGISTER, default_timeout, &res);
|
2007-10-04 07:28:45 +02:00
|
|
|
ret = DdeGetLastError(client_pid);
|
2007-10-08 11:06:08 +02:00
|
|
|
ok(op == NULL, "Expected NULL, got %p\n", op);
|
|
|
|
ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res);
|
2007-10-12 07:11:56 +02:00
|
|
|
ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret);
|
2007-10-04 07:28:45 +02:00
|
|
|
|
|
|
|
res = 0xdeadbeef;
|
|
|
|
DdeGetLastError(client_pid);
|
2007-10-15 21:19:22 +02:00
|
|
|
op = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_WILDCONNECT, default_timeout, &res);
|
2007-10-04 07:28:45 +02:00
|
|
|
ret = DdeGetLastError(client_pid);
|
|
|
|
ok(op == NULL, "Expected NULL, got %p\n", op);
|
|
|
|
ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res);
|
2007-10-12 07:11:56 +02:00
|
|
|
ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret);
|
2007-10-04 07:28:45 +02:00
|
|
|
|
|
|
|
res = 0xdeadbeef;
|
|
|
|
DdeGetLastError(client_pid);
|
2007-10-15 21:19:22 +02:00
|
|
|
op = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_XACT_COMPLETE, default_timeout, &res);
|
2007-10-04 07:28:45 +02:00
|
|
|
ret = DdeGetLastError(client_pid);
|
|
|
|
ok(op == NULL, "Expected NULL, got %p\n", op);
|
|
|
|
ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", res);
|
2007-10-12 07:11:56 +02:00
|
|
|
ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret);
|
2007-10-04 07:28:45 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
DdeFreeStringHandle(client_pid, item);
|
2007-10-04 07:28:45 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
ret = DdeDisconnect(conversation);
|
2007-10-12 07:11:56 +02:00
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
2007-10-04 07:28:45 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
ret = DdeUninitialize(client_pid);
|
2007-10-04 07:28:45 +02:00
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
2007-10-08 11:06:08 +02:00
|
|
|
}
|
2007-10-04 07:28:45 +02:00
|
|
|
|
2007-10-08 11:06:45 +02:00
|
|
|
static DWORD server_pid;
|
|
|
|
|
|
|
|
static HDDEDATA CALLBACK server_ddeml_callback(UINT uType, UINT uFmt, HCONV hconv,
|
|
|
|
HSZ hsz1, HSZ hsz2, HDDEDATA hdata,
|
|
|
|
ULONG_PTR dwData1, ULONG_PTR dwData2)
|
|
|
|
{
|
|
|
|
char str[MAX_PATH], *ptr;
|
2009-01-14 08:29:28 +01:00
|
|
|
HDDEDATA ret = NULL;
|
2007-10-08 11:06:45 +02:00
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
static int msg_index = 0;
|
|
|
|
static HCONV conversation = 0;
|
|
|
|
|
|
|
|
msg_index++;
|
|
|
|
|
|
|
|
switch (uType)
|
|
|
|
{
|
|
|
|
case XTYP_REGISTER:
|
|
|
|
{
|
|
|
|
ok(msg_index == 1, "Expected 1, got %d\n", msg_index);
|
|
|
|
ok(uFmt == 0, "Expected 0, got %d\n", uFmt);
|
|
|
|
ok(hconv == 0, "Expected 0, got %p\n", hconv);
|
|
|
|
ok(hdata == 0, "Expected 0, got %p\n", hdata);
|
|
|
|
ok(dwData1 == 0, "Expected 0, got %08lx\n", dwData1);
|
|
|
|
ok(dwData2 == 0, "Expected 0, got %08lx\n", dwData2);
|
|
|
|
|
|
|
|
size = DdeQueryStringA(server_pid, hsz1, str, MAX_PATH, CP_WINANSI);
|
|
|
|
ok(!lstrcmpA(str, "TestDDEServer"), "Expected TestDDEServer, got %s\n", str);
|
|
|
|
ok(size == 13, "Expected 13, got %d\n", size);
|
|
|
|
|
|
|
|
size = DdeQueryStringA(server_pid, hsz2, str, MAX_PATH, CP_WINANSI);
|
2010-06-23 15:22:29 +02:00
|
|
|
if (!strncmp( str, "TestDDEServer:(", 15 )) /* win9x style */
|
|
|
|
{
|
|
|
|
ok(size == 16 + 2*sizeof(WORD), "Got size %d for %s\n", size, str);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(!strncmp(str, "TestDDEServer(", 14), "Expected TestDDEServer(, got %s\n", str);
|
|
|
|
ok(size == 17 + 2*sizeof(ULONG_PTR), "Got size %d for %s\n", size, str);
|
|
|
|
}
|
|
|
|
ok(str[size - 1] == ')', "Expected ')', got %c\n", str[size - 1]);
|
2007-10-08 11:06:45 +02:00
|
|
|
|
|
|
|
return (HDDEDATA)TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
case XTYP_CONNECT:
|
|
|
|
{
|
|
|
|
ok(msg_index == 2, "Expected 2, got %d\n", msg_index);
|
|
|
|
ok(uFmt == 0, "Expected 0, got %d\n", uFmt);
|
|
|
|
ok(hconv == 0, "Expected 0, got %p\n", hconv);
|
|
|
|
ok(hdata == 0, "Expected 0, got %p\n", hdata);
|
|
|
|
ok(dwData1 == 0, "Expected 0, got %08lx\n", dwData1);
|
|
|
|
ok(dwData2 == FALSE, "Expected FALSE, got %08lx\n", dwData2);
|
|
|
|
|
|
|
|
size = DdeQueryStringA(server_pid, hsz1, str, MAX_PATH, CP_WINANSI);
|
|
|
|
ok(!lstrcmpA(str, "TestDDETopic"), "Expected TestDDETopic, got %s\n", str);
|
|
|
|
ok(size == 12, "Expected 12, got %d\n", size);
|
|
|
|
|
|
|
|
size = DdeQueryStringA(server_pid, hsz2, str, MAX_PATH, CP_WINANSI);
|
|
|
|
ok(!lstrcmpA(str, "TestDDEServer"), "Expected TestDDEServer, got %s\n", str);
|
|
|
|
ok(size == 13, "Expected 13, got %d\n", size);
|
|
|
|
|
|
|
|
return (HDDEDATA)TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
case XTYP_CONNECT_CONFIRM:
|
|
|
|
{
|
|
|
|
conversation = hconv;
|
|
|
|
|
|
|
|
ok(msg_index == 3, "Expected 3, got %d\n", msg_index);
|
|
|
|
ok(uFmt == 0, "Expected 0, got %d\n", uFmt);
|
|
|
|
ok(hconv != NULL, "Expected non-NULL hconv\n");
|
|
|
|
ok(hdata == 0, "Expected 0, got %p\n", hdata);
|
|
|
|
ok(dwData1 == 0, "Expected 0, got %08lx\n", dwData1);
|
|
|
|
ok(dwData2 == FALSE, "Expected FALSE, got %08lx\n", dwData2);
|
|
|
|
|
|
|
|
size = DdeQueryStringA(server_pid, hsz1, str, MAX_PATH, CP_WINANSI);
|
|
|
|
ok(!lstrcmpA(str, "TestDDETopic"), "Expected TestDDETopic, got %s\n", str);
|
|
|
|
ok(size == 12, "Expected 12, got %d\n", size);
|
|
|
|
|
|
|
|
size = DdeQueryStringA(server_pid, hsz2, str, MAX_PATH, CP_WINANSI);
|
|
|
|
ok(!lstrcmpA(str, "TestDDEServer"), "Expected TestDDEServer, got %s\n", str);
|
|
|
|
ok(size == 13, "Expected 13, got %d\n", size);
|
|
|
|
|
|
|
|
return (HDDEDATA)TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
case XTYP_REQUEST:
|
|
|
|
{
|
|
|
|
ok(msg_index == 4 || msg_index == 5 || msg_index == 6,
|
|
|
|
"Expected 4, 5 or 6, got %d\n", msg_index);
|
|
|
|
ok(hconv == conversation, "Expected conversation handle, got %p\n", hconv);
|
|
|
|
ok(hdata == 0, "Expected 0, got %p\n", hdata);
|
|
|
|
ok(dwData1 == 0, "Expected 0, got %08lx\n", dwData1);
|
|
|
|
ok(dwData2 == 0, "Expected 0, got %08lx\n", dwData2);
|
|
|
|
|
|
|
|
if (msg_index == 4)
|
|
|
|
ok(uFmt == 0xbeef, "Expected 0xbeef, got %08x\n", uFmt);
|
|
|
|
else
|
|
|
|
ok(uFmt == CF_TEXT, "Expected CF_TEXT, got %08x\n", uFmt);
|
|
|
|
|
|
|
|
size = DdeQueryStringA(server_pid, hsz1, str, MAX_PATH, CP_WINANSI);
|
|
|
|
ok(!lstrcmpA(str, "TestDDETopic"), "Expected TestDDETopic, got %s\n", str);
|
|
|
|
ok(size == 12, "Expected 12, got %d\n", size);
|
|
|
|
|
|
|
|
size = DdeQueryStringA(server_pid, hsz2, str, MAX_PATH, CP_WINANSI);
|
|
|
|
|
|
|
|
if (msg_index == 5)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ok(!lstrcmpA(str, ""), "Expected empty string, got %s\n", str);
|
|
|
|
ok(size == 1, "Expected 1, got %d\n", size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (msg_index == 6)
|
|
|
|
{
|
|
|
|
ok(!lstrcmpA(str, "request"), "Expected request, got %s\n", str);
|
|
|
|
ok(size == 7, "Expected 7, got %d\n", size);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (msg_index == 6)
|
|
|
|
{
|
|
|
|
lstrcpyA(str, "requested data\r\n");
|
|
|
|
return DdeCreateDataHandle(server_pid, (LPBYTE)str, lstrlenA(str) + 1,
|
|
|
|
0, hsz2, CF_TEXT, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
case XTYP_POKE:
|
|
|
|
{
|
|
|
|
ok(msg_index == 7 || msg_index == 8, "Expected 7 or 8, got %d\n", msg_index);
|
|
|
|
ok(uFmt == CF_TEXT, "Expected CF_TEXT, got %d\n", uFmt);
|
|
|
|
ok(hconv == conversation, "Expected conversation handle, got %p\n", hconv);
|
|
|
|
ok(dwData1 == 0, "Expected 0, got %08lx\n", dwData1);
|
|
|
|
ok(dwData2 == 0, "Expected 0, got %08lx\n", dwData2);
|
|
|
|
|
|
|
|
size = DdeQueryStringA(server_pid, hsz1, str, MAX_PATH, CP_WINANSI);
|
|
|
|
ok(!lstrcmpA(str, "TestDDETopic"), "Expected TestDDETopic, got %s\n", str);
|
|
|
|
ok(size == 12, "Expected 12, got %d\n", size);
|
|
|
|
|
|
|
|
ptr = (LPSTR)DdeAccessData(hdata, &size);
|
|
|
|
ok(!lstrcmpA(ptr, "poke data\r\n"), "Expected 'poke data\\r\\n', got %s\n", ptr);
|
2010-06-24 23:36:24 +02:00
|
|
|
ok(size == 12 || broken(size == 28), /* sizes are rounded up on win9x */
|
|
|
|
"Expected 12, got %d\n", size);
|
2007-10-08 11:06:45 +02:00
|
|
|
DdeUnaccessData(hdata);
|
|
|
|
|
|
|
|
size = DdeQueryStringA(server_pid, hsz2, str, MAX_PATH, CP_WINANSI);
|
|
|
|
if (msg_index == 7)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ok(!lstrcmpA(str, ""), "Expected empty string, got %s\n", str);
|
|
|
|
ok(size == 1, "Expected 1, got %d\n", size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(!lstrcmpA(str, "poke"), "Expected poke, got %s\n", str);
|
|
|
|
ok(size == 4, "Expected 4, got %d\n", size);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (HDDEDATA)DDE_FACK;
|
|
|
|
}
|
|
|
|
|
|
|
|
case XTYP_EXECUTE:
|
|
|
|
{
|
2009-01-14 08:29:28 +01:00
|
|
|
ok(msg_index >= 9 && msg_index <= 11, "Expected 9 or 11, got %d\n", msg_index);
|
2007-10-08 11:06:45 +02:00
|
|
|
ok(uFmt == 0, "Expected 0, got %d\n", uFmt);
|
|
|
|
ok(hconv == conversation, "Expected conversation handle, got %p\n", hconv);
|
|
|
|
ok(dwData1 == 0, "Expected 0, got %08lx\n", dwData1);
|
|
|
|
ok(dwData2 == 0, "Expected 0, got %08lx\n", dwData2);
|
|
|
|
ok(hsz2 == 0, "Expected 0, got %p\n", hsz2);
|
|
|
|
|
|
|
|
size = DdeQueryStringA(server_pid, hsz1, str, MAX_PATH, CP_WINANSI);
|
|
|
|
ok(!lstrcmpA(str, "TestDDETopic"), "Expected TestDDETopic, got %s\n", str);
|
|
|
|
ok(size == 12, "Expected 12, got %d\n", size);
|
|
|
|
|
2009-01-14 08:29:28 +01:00
|
|
|
if (msg_index == 9 || msg_index == 11)
|
2007-10-08 11:06:45 +02:00
|
|
|
{
|
2009-01-14 08:29:28 +01:00
|
|
|
ptr = (LPSTR)DdeAccessData(hdata, &size);
|
|
|
|
|
|
|
|
if (msg_index == 9)
|
|
|
|
{
|
|
|
|
ok(!lstrcmpA(ptr, "[Command(Var)]"), "Expected '[Command(Var)]', got %s\n", ptr);
|
|
|
|
ok(size == 15, "Expected 15, got %d\n", size);
|
|
|
|
ret = (HDDEDATA)DDE_FACK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(!lstrcmpA(ptr, "[BadCommand(Var)]"), "Expected '[BadCommand(Var)]', got %s\n", ptr);
|
|
|
|
ok(size == 18, "Expected 18, got %d\n", size);
|
2009-02-05 09:53:39 +01:00
|
|
|
ret = DDE_FNOTPROCESSED;
|
2009-01-14 08:29:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DdeUnaccessData(hdata);
|
2007-10-08 11:06:45 +02:00
|
|
|
}
|
2009-01-14 08:29:28 +01:00
|
|
|
else if (msg_index == 10)
|
2007-10-08 11:06:45 +02:00
|
|
|
{
|
2009-01-14 08:29:28 +01:00
|
|
|
DWORD rsize = 0;
|
|
|
|
size = 0;
|
|
|
|
|
|
|
|
size = DdeGetData(hdata, NULL, 0, 0);
|
|
|
|
ok(size == 17, "DdeGetData should have returned 17 not %d\n", size);
|
|
|
|
ptr = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
ok(ptr != NULL,"HeapAlloc should have returned ptr not NULL\n");
|
|
|
|
rsize = DdeGetData(hdata, (LPBYTE)ptr, size, 0);
|
|
|
|
ok(rsize == size, "DdeGetData did not return %d bytes but %d\n", size, rsize);
|
|
|
|
|
|
|
|
ok(!lstrcmpA(ptr, "[Command-2(Var)]"), "Expected '[Command-2(Var)]' got %s\n", ptr);
|
|
|
|
ok(size == 17, "Expected 17, got %d\n", size);
|
|
|
|
ret = (HDDEDATA)DDE_FACK;
|
2007-10-08 11:06:45 +02:00
|
|
|
|
2009-01-14 08:29:28 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, ptr);
|
|
|
|
}
|
2007-10-08 11:06:45 +02:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
case XTYP_DISCONNECT:
|
|
|
|
{
|
2009-01-14 08:29:28 +01:00
|
|
|
ok(msg_index == 12, "Expected 12, got %d\n", msg_index);
|
2007-10-08 11:06:45 +02:00
|
|
|
ok(uFmt == 0, "Expected 0, got %d\n", uFmt);
|
|
|
|
ok(hconv == conversation, "Expected conversation handle, got %p\n", hconv);
|
|
|
|
ok(dwData1 == 0, "Expected 0, got %08lx\n", dwData1);
|
|
|
|
ok(dwData2 == 0, "Expected 0, got %08lx\n", dwData2);
|
|
|
|
ok(hsz1 == 0, "Expected 0, got %p\n", hsz2);
|
|
|
|
ok(hsz2 == 0, "Expected 0, got %p\n", hsz2);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
ok(FALSE, "Unhandled msg: %08x\n", uType);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_ddeml_server(HANDLE hproc)
|
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
UINT res;
|
|
|
|
BOOL ret;
|
|
|
|
HSZ server;
|
|
|
|
HDDEDATA hdata;
|
|
|
|
|
|
|
|
/* set up DDE server */
|
|
|
|
server_pid = 0;
|
|
|
|
res = DdeInitialize(&server_pid, server_ddeml_callback, APPCLASS_STANDARD, 0);
|
|
|
|
ok(res == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", res);
|
|
|
|
|
|
|
|
server = DdeCreateStringHandle(server_pid, "TestDDEServer", CP_WINANSI);
|
|
|
|
ok(server != NULL, "Expected non-NULL string handle\n");
|
|
|
|
|
|
|
|
hdata = DdeNameService(server_pid, server, 0, DNS_REGISTER);
|
|
|
|
ok(hdata == (HDDEDATA)TRUE, "Expected TRUE, got %p\n", hdata);
|
|
|
|
|
2007-10-15 21:19:22 +02:00
|
|
|
while (MsgWaitForMultipleObjects( 1, &hproc, FALSE, INFINITE, QS_ALLINPUT ) != 0)
|
2007-10-08 11:06:45 +02:00
|
|
|
{
|
|
|
|
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
|
2007-10-15 21:19:22 +02:00
|
|
|
}
|
2007-10-08 11:06:45 +02:00
|
|
|
ret = DdeUninitialize(server_pid);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
2007-10-15 21:19:22 +02:00
|
|
|
GetExitCodeProcess( hproc, &res );
|
|
|
|
ok( !res, "client failed with %u error(s)\n", res );
|
2007-10-08 11:06:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HWND client_hwnd, server_hwnd;
|
|
|
|
static ATOM server, topic, item;
|
|
|
|
static HGLOBAL execute_hglobal;
|
|
|
|
|
|
|
|
static LRESULT WINAPI dde_msg_client_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
char str[MAX_PATH];
|
|
|
|
UINT_PTR lo, hi;
|
|
|
|
DDEDATA *data;
|
|
|
|
DDEACK *ack;
|
|
|
|
DWORD size;
|
|
|
|
LPSTR ptr;
|
|
|
|
|
|
|
|
static int msg_index = 0;
|
|
|
|
|
|
|
|
if (msg < WM_DDE_FIRST || msg > WM_DDE_LAST)
|
|
|
|
return DefWindowProcA(hwnd, msg, wparam, lparam);
|
|
|
|
|
|
|
|
msg_index++;
|
|
|
|
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_DDE_INITIATE:
|
|
|
|
{
|
|
|
|
ok(msg_index == 1, "Expected 1, got %d\n", msg_index);
|
|
|
|
ok(wparam == (WPARAM)client_hwnd, "Expected client hwnd, got %08lx\n", wparam);
|
|
|
|
|
|
|
|
size = GlobalGetAtomNameA(LOWORD(lparam), str, MAX_PATH);
|
|
|
|
ok(LOWORD(lparam) == server, "Expected server atom, got %08x\n", LOWORD(lparam));
|
|
|
|
ok(!lstrcmpA(str, "TestDDEServer"), "Expected TestDDEServer, got %s\n", str);
|
|
|
|
ok(size == 13, "Expected 13, got %d\n", size);
|
|
|
|
|
|
|
|
size = GlobalGetAtomNameA(HIWORD(lparam), str, MAX_PATH);
|
|
|
|
ok(HIWORD(lparam) == topic, "Expected topic atom, got %08x\n", HIWORD(lparam));
|
|
|
|
ok(!lstrcmpA(str, "TestDDETopic"), "Expected TestDDETopic, got %s\n", str);
|
|
|
|
ok(size == 12, "Expected 12, got %d\n", size);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_DDE_ACK:
|
|
|
|
{
|
2009-01-14 08:29:28 +01:00
|
|
|
ok((msg_index >= 2 && msg_index <= 4) || (msg_index >= 6 && msg_index <= 11),
|
|
|
|
"Expected 2, 3, 4, 6, 7, 8, 9, 10 or 11, got %d\n", msg_index);
|
2007-10-08 11:06:45 +02:00
|
|
|
|
|
|
|
if (msg_index == 2)
|
|
|
|
{
|
|
|
|
server_hwnd = (HWND)wparam;
|
|
|
|
ok(wparam != 0, "Expected non-NULL wparam, got %08lx\n", wparam);
|
|
|
|
|
|
|
|
size = GlobalGetAtomNameA(LOWORD(lparam), str, MAX_PATH);
|
|
|
|
ok(LOWORD(lparam) == server, "Expected server atom, got %08x\n", LOWORD(lparam));
|
|
|
|
ok(!lstrcmpA(str, "TestDDEServer"), "Expected TestDDEServer, got %s\n", str);
|
|
|
|
ok(size == 13, "Expected 13, got %d\n", size);
|
|
|
|
|
|
|
|
size = GlobalGetAtomNameA(HIWORD(lparam), str, MAX_PATH);
|
|
|
|
ok(HIWORD(lparam) == topic, "Expected topic atom, got %08x\n", HIWORD(lparam));
|
|
|
|
ok(!lstrcmpA(str, "TestDDETopic"), "Expected TestDDETopic, got %s\n", str);
|
|
|
|
ok(size == 12, "Expected 12, got %d\n", size);
|
|
|
|
}
|
2009-01-14 08:29:28 +01:00
|
|
|
else if (msg_index >= 9 && msg_index <= 11)
|
2007-10-08 11:06:45 +02:00
|
|
|
{
|
|
|
|
ok(wparam == (WPARAM)server_hwnd, "Expected server hwnd, got %08lx\n", wparam);
|
|
|
|
|
|
|
|
UnpackDDElParam(WM_DDE_ACK, lparam, &lo, &hi);
|
|
|
|
|
|
|
|
ack = (DDEACK *)&lo;
|
|
|
|
ok(ack->bAppReturnCode == 0, "Expected 0, got %d\n", ack->bAppReturnCode);
|
|
|
|
ok(ack->reserved == 0, "Expected 0, got %d\n", ack->reserved);
|
|
|
|
ok(ack->fBusy == FALSE, "Expected FALSE, got %d\n", ack->fBusy);
|
|
|
|
|
2010-06-24 23:36:24 +02:00
|
|
|
ok(hi == (UINT_PTR)execute_hglobal, "Expected execute hglobal, got %08lx\n", hi);
|
2007-10-08 11:06:45 +02:00
|
|
|
ptr = GlobalLock((HGLOBAL)hi);
|
|
|
|
|
|
|
|
if (msg_index == 9)
|
|
|
|
{
|
|
|
|
ok(ack->fAck == TRUE, "Expected TRUE, got %d\n", ack->fAck);
|
|
|
|
ok(!lstrcmpA(ptr, "[Command(Var)]"), "Expected '[Command(Var)]', got %s\n", ptr);
|
2009-01-14 08:29:28 +01:00
|
|
|
} else if (msg_index == 10)
|
|
|
|
{
|
|
|
|
ok(ack->fAck == TRUE, "Expected TRUE, got %d\n", ack->fAck);
|
|
|
|
ok(!lstrcmpA(ptr, "[Command-2(Var)]"), "Expected '[Command-2(Var)]', got %s\n", ptr);
|
2007-10-08 11:06:45 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(ack->fAck == FALSE, "Expected FALSE, got %d\n", ack->fAck);
|
|
|
|
ok(!lstrcmpA(ptr, "[BadCommand(Var)]"), "Expected '[BadCommand(Var)]', got %s\n", ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
GlobalUnlock((HGLOBAL)hi);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(wparam == (WPARAM)server_hwnd, "Expected server hwnd, got %08lx\n", wparam);
|
|
|
|
|
|
|
|
UnpackDDElParam(WM_DDE_ACK, lparam, &lo, &hi);
|
|
|
|
|
|
|
|
ack = (DDEACK *)&lo;
|
|
|
|
ok(ack->bAppReturnCode == 0, "Expected 0, got %d\n", ack->bAppReturnCode);
|
|
|
|
ok(ack->reserved == 0, "Expected 0, got %d\n", ack->reserved);
|
|
|
|
ok(ack->fBusy == FALSE, "Expected FALSE, got %d\n", ack->fBusy);
|
|
|
|
|
|
|
|
if (msg_index >= 7)
|
|
|
|
ok(ack->fAck == TRUE, "Expected TRUE, got %d\n", ack->fAck);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (msg_index == 6) todo_wine
|
|
|
|
ok(ack->fAck == FALSE, "Expected FALSE, got %d\n", ack->fAck);
|
|
|
|
}
|
|
|
|
|
|
|
|
size = GlobalGetAtomNameA(hi, str, MAX_PATH);
|
|
|
|
if (msg_index == 3)
|
|
|
|
{
|
|
|
|
ok(hi == item, "Expected item atom, got %08lx\n", hi);
|
|
|
|
ok(!lstrcmpA(str, "request"), "Expected request, got %s\n", str);
|
|
|
|
ok(size == 7, "Expected 7, got %d\n", size);
|
|
|
|
}
|
|
|
|
else if (msg_index == 4 || msg_index == 7)
|
|
|
|
{
|
|
|
|
ok(hi == 0, "Expected 0, got %08lx\n", hi);
|
|
|
|
ok(size == 0, "Expected empty string, got %d\n", size);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(hi == item, "Expected item atom, got %08lx\n", hi);
|
|
|
|
if (msg_index == 6) todo_wine
|
|
|
|
{
|
|
|
|
ok(!lstrcmpA(str, "poke"), "Expected poke, got %s\n", str);
|
|
|
|
ok(size == 4, "Expected 4, got %d\n", size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_DDE_DATA:
|
|
|
|
{
|
|
|
|
ok(msg_index == 5, "Expected 5, got %d\n", msg_index);
|
|
|
|
ok(wparam == (WPARAM)server_hwnd, "Expected server hwnd, got %08lx\n", wparam);
|
|
|
|
|
|
|
|
UnpackDDElParam(WM_DDE_DATA, lparam, &lo, &hi);
|
|
|
|
|
|
|
|
data = GlobalLock((HGLOBAL)lo);
|
|
|
|
ok(data->unused == 0, "Expected 0, got %d\n", data->unused);
|
|
|
|
ok(data->fResponse == TRUE, "Expected TRUE, got %d\n", data->fResponse);
|
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
ok(data->fRelease == TRUE, "Expected TRUE, got %d\n", data->fRelease);
|
|
|
|
}
|
|
|
|
ok(data->fAckReq == 0, "Expected 0, got %d\n", data->fAckReq);
|
|
|
|
ok(data->cfFormat == CF_TEXT, "Expected CF_TEXT, got %d\n", data->cfFormat);
|
|
|
|
ok(!lstrcmpA((LPSTR)data->Value, "requested data\r\n"),
|
|
|
|
"Expeted 'requested data\\r\\n', got %s\n", data->Value);
|
|
|
|
GlobalUnlock((HGLOBAL)lo);
|
|
|
|
|
|
|
|
size = GlobalGetAtomNameA(hi, str, MAX_PATH);
|
|
|
|
ok(hi == item, "Expected item atom, got %08x\n", HIWORD(lparam));
|
|
|
|
ok(!lstrcmpA(str, "request"), "Expected request, got %s\n", str);
|
|
|
|
ok(size == 7, "Expected 7, got %d\n", size);
|
|
|
|
|
|
|
|
GlobalFree((HGLOBAL)lo);
|
|
|
|
GlobalDeleteAtom(hi);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
ok(FALSE, "Unhandled msg: %08x\n", msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
return DefWindowProcA(hwnd, msg, wparam, lparam);
|
|
|
|
}
|
|
|
|
|
2009-01-28 22:34:52 +01:00
|
|
|
static HGLOBAL create_poke(void)
|
2007-10-08 11:06:45 +02:00
|
|
|
{
|
|
|
|
HGLOBAL hglobal;
|
|
|
|
DDEPOKE *poke;
|
|
|
|
DWORD size;
|
|
|
|
|
2008-07-08 16:18:21 +02:00
|
|
|
size = FIELD_OFFSET(DDEPOKE, Value[sizeof("poke data\r\n")]);
|
2007-10-08 11:06:45 +02:00
|
|
|
hglobal = GlobalAlloc(GMEM_DDESHARE, size);
|
|
|
|
ok(hglobal != 0, "Expected non-NULL hglobal\n");
|
|
|
|
|
|
|
|
poke = GlobalLock(hglobal);
|
|
|
|
poke->unused = 0;
|
|
|
|
poke->fRelease = TRUE;
|
|
|
|
poke->fReserved = TRUE;
|
|
|
|
poke->cfFormat = CF_TEXT;
|
|
|
|
lstrcpyA((LPSTR)poke->Value, "poke data\r\n");
|
|
|
|
GlobalUnlock(hglobal);
|
|
|
|
|
|
|
|
return hglobal;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HGLOBAL create_execute(LPCSTR command)
|
|
|
|
{
|
|
|
|
HGLOBAL hglobal;
|
|
|
|
LPSTR ptr;
|
|
|
|
|
|
|
|
hglobal = GlobalAlloc(GMEM_DDESHARE, lstrlenA(command) + 1);
|
|
|
|
ok(hglobal != 0, "Expected non-NULL hglobal\n");
|
|
|
|
|
|
|
|
ptr = GlobalLock(hglobal);
|
|
|
|
lstrcpyA(ptr, command);
|
|
|
|
GlobalUnlock(hglobal);
|
|
|
|
|
|
|
|
return hglobal;
|
|
|
|
}
|
|
|
|
|
2009-01-28 22:34:52 +01:00
|
|
|
static void test_msg_client(void)
|
2007-10-08 11:06:45 +02:00
|
|
|
{
|
|
|
|
HGLOBAL hglobal;
|
|
|
|
LPARAM lparam;
|
|
|
|
|
|
|
|
create_dde_window(&client_hwnd, "dde_client", dde_msg_client_wndproc);
|
|
|
|
|
|
|
|
server = GlobalAddAtomA("TestDDEServer");
|
|
|
|
ok(server != 0, "Expected non-NULL server\n");
|
|
|
|
|
|
|
|
topic = GlobalAddAtomA("TestDDETopic");
|
|
|
|
ok(topic != 0, "Expected non-NULL topic\n");
|
|
|
|
|
|
|
|
SendMessageA(HWND_BROADCAST, WM_DDE_INITIATE, (WPARAM)client_hwnd, MAKELONG(server, topic));
|
|
|
|
|
|
|
|
GlobalDeleteAtom(server);
|
|
|
|
GlobalDeleteAtom(topic);
|
|
|
|
|
|
|
|
flush_events();
|
|
|
|
|
|
|
|
item = GlobalAddAtom("request");
|
|
|
|
ok(item != 0, "Expected non-NULL item\n");
|
|
|
|
|
|
|
|
/* WM_DDE_REQUEST, bad clipboard format */
|
|
|
|
lparam = PackDDElParam(WM_DDE_REQUEST, 0xdeadbeef, item);
|
|
|
|
PostMessageA(server_hwnd, WM_DDE_REQUEST, (WPARAM)client_hwnd, lparam);
|
|
|
|
|
|
|
|
flush_events();
|
|
|
|
|
|
|
|
/* WM_DDE_REQUEST, no item */
|
|
|
|
lparam = PackDDElParam(WM_DDE_REQUEST, CF_TEXT, 0);
|
|
|
|
PostMessageA(server_hwnd, WM_DDE_REQUEST, (WPARAM)client_hwnd, lparam);
|
|
|
|
|
|
|
|
flush_events();
|
|
|
|
|
|
|
|
/* WM_DDE_REQUEST, no client hwnd */
|
|
|
|
lparam = PackDDElParam(WM_DDE_REQUEST, CF_TEXT, item);
|
|
|
|
PostMessageA(server_hwnd, WM_DDE_REQUEST, 0, lparam);
|
|
|
|
|
|
|
|
flush_events();
|
|
|
|
|
|
|
|
/* WM_DDE_REQUEST, correct params */
|
|
|
|
lparam = PackDDElParam(WM_DDE_REQUEST, CF_TEXT, item);
|
|
|
|
PostMessageA(server_hwnd, WM_DDE_REQUEST, (WPARAM)client_hwnd, lparam);
|
|
|
|
|
|
|
|
flush_events();
|
|
|
|
|
|
|
|
GlobalDeleteAtom(item);
|
|
|
|
item = GlobalAddAtomA("poke");
|
|
|
|
ok(item != 0, "Expected non-NULL item\n");
|
|
|
|
|
|
|
|
hglobal = create_poke();
|
|
|
|
|
|
|
|
/* WM_DDE_POKE, no ddepoke */
|
|
|
|
lparam = PackDDElParam(WM_DDE_POKE, 0, item);
|
2008-11-05 21:30:41 +01:00
|
|
|
/* win9x returns 0 here and crashes in PostMessageA */
|
|
|
|
if (lparam) {
|
|
|
|
PostMessageA(server_hwnd, WM_DDE_POKE, (WPARAM)client_hwnd, lparam);
|
|
|
|
flush_events();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("no lparam for WM_DDE_POKE\n");
|
2007-10-08 11:06:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* WM_DDE_POKE, no item */
|
|
|
|
lparam = PackDDElParam(WM_DDE_POKE, (UINT_PTR)hglobal, 0);
|
|
|
|
PostMessageA(server_hwnd, WM_DDE_POKE, (WPARAM)client_hwnd, lparam);
|
|
|
|
|
|
|
|
flush_events();
|
|
|
|
|
|
|
|
hglobal = create_poke();
|
|
|
|
|
|
|
|
/* WM_DDE_POKE, no client hwnd */
|
|
|
|
lparam = PackDDElParam(WM_DDE_POKE, (UINT_PTR)hglobal, item);
|
|
|
|
PostMessageA(server_hwnd, WM_DDE_POKE, 0, lparam);
|
|
|
|
|
|
|
|
flush_events();
|
|
|
|
|
|
|
|
/* WM_DDE_POKE, all params correct */
|
|
|
|
lparam = PackDDElParam(WM_DDE_POKE, (UINT_PTR)hglobal, item);
|
|
|
|
PostMessageA(server_hwnd, WM_DDE_POKE, (WPARAM)client_hwnd, lparam);
|
|
|
|
|
|
|
|
flush_events();
|
|
|
|
|
|
|
|
execute_hglobal = create_execute("[Command(Var)]");
|
|
|
|
|
|
|
|
/* WM_DDE_EXECUTE, no lparam */
|
|
|
|
PostMessageA(server_hwnd, WM_DDE_EXECUTE, (WPARAM)client_hwnd, 0);
|
|
|
|
|
|
|
|
flush_events();
|
|
|
|
|
|
|
|
/* WM_DDE_EXECUTE, no hglobal */
|
|
|
|
lparam = PackDDElParam(WM_DDE_EXECUTE, 0, 0);
|
|
|
|
PostMessageA(server_hwnd, WM_DDE_EXECUTE, (WPARAM)client_hwnd, lparam);
|
|
|
|
|
|
|
|
flush_events();
|
|
|
|
|
|
|
|
/* WM_DDE_EXECUTE, no client hwnd */
|
|
|
|
lparam = PackDDElParam(WM_DDE_EXECUTE, 0, (UINT_PTR)execute_hglobal);
|
|
|
|
PostMessageA(server_hwnd, WM_DDE_EXECUTE, 0, lparam);
|
|
|
|
|
|
|
|
flush_events();
|
|
|
|
|
|
|
|
/* WM_DDE_EXECUTE, all params correct */
|
|
|
|
lparam = PackDDElParam(WM_DDE_EXECUTE, 0, (UINT_PTR)execute_hglobal);
|
|
|
|
PostMessageA(server_hwnd, WM_DDE_EXECUTE, (WPARAM)client_hwnd, lparam);
|
|
|
|
|
|
|
|
flush_events();
|
2009-01-14 08:29:28 +01:00
|
|
|
|
|
|
|
GlobalFree(execute_hglobal);
|
|
|
|
execute_hglobal = create_execute("[Command-2(Var)]");
|
|
|
|
|
|
|
|
/* WM_DDE_EXECUTE, all params correct */
|
|
|
|
lparam = PackDDElParam(WM_DDE_EXECUTE, 0, (UINT_PTR)execute_hglobal);
|
|
|
|
PostMessageA(server_hwnd, WM_DDE_EXECUTE, (WPARAM)client_hwnd, lparam);
|
|
|
|
|
|
|
|
flush_events();
|
2007-10-08 11:06:45 +02:00
|
|
|
|
|
|
|
GlobalFree(execute_hglobal);
|
|
|
|
execute_hglobal = create_execute("[BadCommand(Var)]");
|
|
|
|
|
|
|
|
/* WM_DDE_EXECUTE that will get rejected */
|
|
|
|
lparam = PackDDElParam(WM_DDE_EXECUTE, 0, (UINT_PTR)execute_hglobal);
|
|
|
|
PostMessageA(server_hwnd, WM_DDE_EXECUTE, (WPARAM)client_hwnd, lparam);
|
|
|
|
|
|
|
|
flush_events();
|
|
|
|
|
2008-09-02 12:46:51 +02:00
|
|
|
destroy_dde_window(&client_hwnd, "dde_client");
|
2007-10-08 11:06:45 +02:00
|
|
|
}
|
|
|
|
|
2010-06-23 14:19:51 +02:00
|
|
|
static LRESULT WINAPI hook_dde_client_wndprocA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
2007-10-08 11:06:08 +02:00
|
|
|
{
|
|
|
|
UINT_PTR lo, hi;
|
2007-10-04 07:28:45 +02:00
|
|
|
|
2010-06-23 14:19:51 +02:00
|
|
|
trace("hook_dde_client_wndprocA: %p %04x %08lx %08lx\n", hwnd, msg, wparam, lparam);
|
2007-10-04 07:28:45 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
switch (msg)
|
2007-10-04 07:28:45 +02:00
|
|
|
{
|
2007-10-08 11:06:08 +02:00
|
|
|
case WM_DDE_ACK:
|
|
|
|
UnpackDDElParam(WM_DDE_ACK, lparam, &lo, &hi);
|
|
|
|
trace("WM_DDE_ACK: status %04lx hglobal %p\n", lo, (HGLOBAL)hi);
|
|
|
|
break;
|
2007-10-04 07:28:45 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
default:
|
|
|
|
break;
|
2007-10-04 07:28:45 +02:00
|
|
|
}
|
2007-10-08 11:06:08 +02:00
|
|
|
return CallWindowProcA(old_dde_client_wndproc, hwnd, msg, wparam, lparam);
|
|
|
|
}
|
2007-10-04 07:28:45 +02:00
|
|
|
|
2010-06-23 14:19:51 +02:00
|
|
|
static LRESULT WINAPI hook_dde_client_wndprocW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
2007-10-08 11:06:08 +02:00
|
|
|
{
|
2010-06-23 14:19:51 +02:00
|
|
|
UINT_PTR lo, hi;
|
|
|
|
|
|
|
|
trace("hook_dde_client_wndprocW: %p %04x %08lx %08lx\n", hwnd, msg, wparam, lparam);
|
|
|
|
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_DDE_ACK:
|
|
|
|
UnpackDDElParam(WM_DDE_ACK, lparam, &lo, &hi);
|
|
|
|
trace("WM_DDE_ACK: status %04lx hglobal %p\n", lo, (HGLOBAL)hi);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return CallWindowProcW(old_dde_client_wndproc, hwnd, msg, wparam, lparam);
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT WINAPI dde_server_wndprocA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
static BOOL client_unicode, conv_unicode;
|
|
|
|
static int step;
|
2007-10-04 07:28:45 +02:00
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
switch (msg)
|
2007-10-04 07:28:45 +02:00
|
|
|
{
|
2007-10-08 11:06:08 +02:00
|
|
|
case WM_DDE_INITIATE:
|
2007-10-04 07:28:45 +02:00
|
|
|
{
|
2007-10-08 11:06:08 +02:00
|
|
|
ATOM aService = GlobalAddAtomW(TEST_DDE_SERVICE);
|
2007-10-04 07:28:45 +02:00
|
|
|
|
2010-06-23 14:19:51 +02:00
|
|
|
trace("server A: got WM_DDE_INITIATE from %p (%s) with %08lx\n",
|
|
|
|
(HWND)wparam, client_unicode ? "Unicode" : "ANSI", lparam);
|
2007-10-08 11:06:08 +02:00
|
|
|
|
|
|
|
if (LOWORD(lparam) == aService)
|
|
|
|
{
|
2010-06-23 14:19:51 +02:00
|
|
|
client_unicode = IsWindowUnicode((HWND)wparam);
|
|
|
|
conv_unicode = client_unicode;
|
|
|
|
if (step >= 10) client_unicode = !client_unicode; /* change the client window type */
|
|
|
|
|
|
|
|
if (client_unicode)
|
|
|
|
old_dde_client_wndproc = (WNDPROC)SetWindowLongPtrW((HWND)wparam, GWLP_WNDPROC,
|
|
|
|
(ULONG_PTR)hook_dde_client_wndprocW);
|
|
|
|
else
|
|
|
|
old_dde_client_wndproc = (WNDPROC)SetWindowLongPtrA((HWND)wparam, GWLP_WNDPROC,
|
|
|
|
(ULONG_PTR)hook_dde_client_wndprocA);
|
2007-10-08 11:06:08 +02:00
|
|
|
trace("server: sending WM_DDE_ACK to %p\n", (HWND)wparam);
|
2009-04-24 13:38:58 +02:00
|
|
|
SendMessageW((HWND)wparam, WM_DDE_ACK, (WPARAM)hwnd, PackDDElParam(WM_DDE_ACK, aService, 0));
|
2007-10-08 11:06:08 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
GlobalDeleteAtom(aService);
|
|
|
|
return 0;
|
2007-10-04 07:28:45 +02:00
|
|
|
}
|
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
case WM_DDE_EXECUTE:
|
2007-10-04 07:28:45 +02:00
|
|
|
{
|
2007-10-08 11:06:08 +02:00
|
|
|
DDEACK ack;
|
|
|
|
WORD status;
|
|
|
|
LPCSTR cmd;
|
|
|
|
UINT_PTR lo, hi;
|
|
|
|
|
2010-06-23 14:19:51 +02:00
|
|
|
trace("server A: got WM_DDE_EXECUTE from %p with %08lx\n", (HWND)wparam, lparam);
|
2007-10-08 11:06:08 +02:00
|
|
|
|
|
|
|
UnpackDDElParam(WM_DDE_EXECUTE, lparam, &lo, &hi);
|
|
|
|
trace("%08lx => lo %04lx hi %04lx\n", lparam, lo, hi);
|
|
|
|
|
|
|
|
ack.bAppReturnCode = 0;
|
|
|
|
ack.reserved = 0;
|
|
|
|
ack.fBusy = 0;
|
2010-06-23 14:19:51 +02:00
|
|
|
/* We have to send a negative acknowledge even if we don't
|
|
|
|
* accept the command, otherwise Windows goes mad and next time
|
|
|
|
* we send an acknowledge DDEML drops the connection.
|
|
|
|
* Not sure how to call it: a bug or a feature.
|
|
|
|
*/
|
|
|
|
ack.fAck = 0;
|
2007-10-08 11:06:08 +02:00
|
|
|
|
2010-06-23 14:19:51 +02:00
|
|
|
if ((cmd = GlobalLock((HGLOBAL)hi)))
|
2007-10-08 11:06:08 +02:00
|
|
|
{
|
2010-06-23 14:19:51 +02:00
|
|
|
ack.fAck = !lstrcmpA(cmd, exec_cmdA) || !lstrcmpW((LPCWSTR)cmd, exec_cmdW);
|
|
|
|
|
|
|
|
switch (step % 5)
|
|
|
|
{
|
|
|
|
case 0: /* bad command */
|
|
|
|
trace( "server A got unhandled command\n" );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: /* ANSI command */
|
|
|
|
if (!conv_unicode)
|
|
|
|
ok( !lstrcmpA(cmd, exec_cmdA), "server A got wrong command '%s'\n", cmd );
|
|
|
|
else /* we get garbage as the A command was mapped W->A */
|
2011-01-16 15:14:32 +01:00
|
|
|
ok( cmd[0] != exec_cmdA[0], "server A got wrong command '%s'\n", cmd );
|
2010-06-23 14:19:51 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: /* ANSI command in Unicode format */
|
|
|
|
if (conv_unicode)
|
|
|
|
ok( !lstrcmpA(cmd, exec_cmdA), "server A got wrong command '%s'\n", cmd );
|
|
|
|
else
|
|
|
|
ok( !lstrcmpW((LPCWSTR)cmd, exec_cmdAW), "server A got wrong command '%s'\n", cmd );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: /* Unicode command */
|
|
|
|
if (!conv_unicode)
|
|
|
|
ok( !lstrcmpW((LPCWSTR)cmd, exec_cmdW), "server A got wrong command '%s'\n", cmd );
|
|
|
|
else /* correctly mapped W->A */
|
|
|
|
ok( !lstrcmpA(cmd, exec_cmdWA), "server A got wrong command '%s'\n", cmd );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4: /* Unicode command in ANSI format */
|
|
|
|
if (!conv_unicode)
|
|
|
|
ok( !lstrcmpA(cmd, exec_cmdWA), "server A got wrong command '%s'\n", cmd );
|
|
|
|
else /* we get garbage as the A command was mapped W->A */
|
2011-01-16 15:14:32 +01:00
|
|
|
ok( cmd[0] != exec_cmdWA[0], "server A got wrong command '%s'\n", cmd );
|
2010-06-23 14:19:51 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
GlobalUnlock((HGLOBAL)hi);
|
2007-10-08 11:06:08 +02:00
|
|
|
}
|
2010-06-23 14:19:51 +02:00
|
|
|
else ok( 0, "bad command data %lx\n", hi );
|
2007-10-08 11:06:08 +02:00
|
|
|
|
2010-06-23 14:19:51 +02:00
|
|
|
step++;
|
|
|
|
trace("server A: posting %s WM_DDE_ACK to %p\n", ack.fAck ? "POSITIVE" : "NEGATIVE", (HWND)wparam);
|
2007-10-08 11:06:08 +02:00
|
|
|
|
|
|
|
status = *((WORD *)&ack);
|
|
|
|
lparam = ReuseDDElParam(lparam, WM_DDE_EXECUTE, WM_DDE_ACK, status, hi);
|
|
|
|
|
|
|
|
PostMessageW((HWND)wparam, WM_DDE_ACK, (WPARAM)hwnd, lparam);
|
|
|
|
return 0;
|
2007-10-04 07:28:45 +02:00
|
|
|
}
|
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
case WM_DDE_TERMINATE:
|
2007-10-04 07:28:45 +02:00
|
|
|
{
|
2007-10-08 11:06:08 +02:00
|
|
|
DDEACK ack;
|
|
|
|
WORD status;
|
|
|
|
|
2010-06-23 14:19:51 +02:00
|
|
|
trace("server A: got WM_DDE_TERMINATE from %p with %08lx\n", (HWND)wparam, lparam);
|
2007-10-08 11:06:08 +02:00
|
|
|
|
|
|
|
ack.bAppReturnCode = 0;
|
|
|
|
ack.reserved = 0;
|
|
|
|
ack.fBusy = 0;
|
|
|
|
ack.fAck = 1;
|
|
|
|
|
2010-06-23 14:19:51 +02:00
|
|
|
trace("server A: posting %s WM_DDE_ACK to %p\n", ack.fAck ? "POSITIVE" : "NEGATIVE", (HWND)wparam);
|
2007-10-08 11:06:08 +02:00
|
|
|
|
|
|
|
status = *((WORD *)&ack);
|
|
|
|
lparam = PackDDElParam(WM_DDE_ACK, status, 0);
|
|
|
|
|
|
|
|
PostMessageW((HWND)wparam, WM_DDE_ACK, (WPARAM)hwnd, lparam);
|
|
|
|
return 0;
|
2007-10-04 07:28:45 +02:00
|
|
|
}
|
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
default:
|
|
|
|
break;
|
2007-10-04 07:28:45 +02:00
|
|
|
}
|
|
|
|
|
2007-10-08 11:06:08 +02:00
|
|
|
return DefWindowProcA(hwnd, msg, wparam, lparam);
|
|
|
|
}
|
2007-10-04 07:28:45 +02:00
|
|
|
|
2010-06-23 14:19:51 +02:00
|
|
|
static LRESULT WINAPI dde_server_wndprocW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
2007-10-08 11:06:08 +02:00
|
|
|
{
|
2010-06-23 14:19:51 +02:00
|
|
|
static BOOL client_unicode, conv_unicode;
|
|
|
|
static int step;
|
2007-10-08 11:06:08 +02:00
|
|
|
|
2010-06-23 14:19:51 +02:00
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_DDE_INITIATE:
|
|
|
|
{
|
|
|
|
ATOM aService = GlobalAddAtomW(TEST_DDE_SERVICE);
|
2007-10-08 11:06:08 +02:00
|
|
|
|
2010-06-23 14:19:51 +02:00
|
|
|
if (LOWORD(lparam) == aService)
|
|
|
|
{
|
|
|
|
client_unicode = IsWindowUnicode((HWND)wparam);
|
|
|
|
conv_unicode = client_unicode;
|
|
|
|
if (step >= 10) client_unicode = !client_unicode; /* change the client window type */
|
|
|
|
|
|
|
|
if (client_unicode)
|
|
|
|
old_dde_client_wndproc = (WNDPROC)SetWindowLongPtrW((HWND)wparam, GWLP_WNDPROC,
|
|
|
|
(ULONG_PTR)hook_dde_client_wndprocW);
|
|
|
|
else
|
|
|
|
old_dde_client_wndproc = (WNDPROC)SetWindowLongPtrA((HWND)wparam, GWLP_WNDPROC,
|
|
|
|
(ULONG_PTR)hook_dde_client_wndprocA);
|
|
|
|
trace("server W: sending WM_DDE_ACK to %p\n", (HWND)wparam);
|
|
|
|
SendMessageW((HWND)wparam, WM_DDE_ACK, (WPARAM)hwnd, PackDDElParam(WM_DDE_ACK, aService, 0));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
GlobalDeleteAtom(aService);
|
2007-10-08 11:06:08 +02:00
|
|
|
|
2010-06-23 14:19:51 +02:00
|
|
|
trace("server W: got WM_DDE_INITIATE from %p with %08lx (client %s conv %s)\n", (HWND)wparam,
|
|
|
|
lparam, client_unicode ? "Unicode" : "ANSI", conv_unicode ? "Unicode" : "ANSI" );
|
2007-10-08 11:06:08 +02:00
|
|
|
|
2010-06-23 14:19:51 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_DDE_EXECUTE:
|
|
|
|
{
|
|
|
|
DDEACK ack;
|
|
|
|
WORD status;
|
|
|
|
LPCSTR cmd;
|
|
|
|
UINT_PTR lo, hi;
|
2007-10-08 11:06:08 +02:00
|
|
|
|
2010-06-23 14:19:51 +02:00
|
|
|
trace("server W: got WM_DDE_EXECUTE from %p with %08lx\n", (HWND)wparam, lparam);
|
2007-10-08 11:06:08 +02:00
|
|
|
|
2010-06-23 14:19:51 +02:00
|
|
|
UnpackDDElParam(WM_DDE_EXECUTE, lparam, &lo, &hi);
|
|
|
|
trace("%08lx => lo %04lx hi %04lx\n", lparam, lo, hi);
|
|
|
|
|
|
|
|
ack.bAppReturnCode = 0;
|
|
|
|
ack.reserved = 0;
|
|
|
|
ack.fBusy = 0;
|
|
|
|
/* We have to send a negative acknowledge even if we don't
|
|
|
|
* accept the command, otherwise Windows goes mad and next time
|
|
|
|
* we send an acknowledge DDEML drops the connection.
|
|
|
|
* Not sure how to call it: a bug or a feature.
|
|
|
|
*/
|
|
|
|
ack.fAck = 0;
|
|
|
|
|
|
|
|
if ((cmd = GlobalLock((HGLOBAL)hi)))
|
|
|
|
{
|
|
|
|
ack.fAck = !lstrcmpA(cmd, exec_cmdA) || !lstrcmpW((LPCWSTR)cmd, exec_cmdW);
|
|
|
|
|
|
|
|
switch (step % 5)
|
|
|
|
{
|
|
|
|
case 0: /* bad command */
|
|
|
|
trace( "server W got unhandled command\n" );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: /* ANSI command */
|
|
|
|
if (conv_unicode && !client_unicode) /* W->A mapping -> garbage */
|
2011-01-16 15:14:32 +01:00
|
|
|
ok( cmd[0] != exec_cmdA[0], "server W got wrong command '%s'\n", cmd );
|
2010-06-23 14:19:51 +02:00
|
|
|
else if (!conv_unicode && client_unicode) /* A->W mapping */
|
|
|
|
ok( !lstrcmpW((LPCWSTR)cmd, exec_cmdAW), "server W got wrong command '%s'\n", cmd );
|
|
|
|
else
|
|
|
|
ok( !lstrcmpA(cmd, exec_cmdA), "server W got wrong command '%s'\n", cmd );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: /* ANSI command in Unicode format */
|
|
|
|
if (conv_unicode && !client_unicode) /* W->A mapping */
|
|
|
|
ok( !lstrcmpA(cmd, exec_cmdA), "server W got wrong command '%s'\n", cmd );
|
|
|
|
else if (!conv_unicode && client_unicode) /* A->W mapping */
|
|
|
|
ok( *(WCHAR *)cmd == exec_cmdAW[0], "server W got wrong command '%s'\n", cmd );
|
|
|
|
else
|
|
|
|
ok( !lstrcmpW((LPCWSTR)cmd, exec_cmdAW), "server W got wrong command '%s'\n", cmd );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: /* Unicode command */
|
|
|
|
if (conv_unicode && !client_unicode) /* W->A mapping */
|
|
|
|
ok( !lstrcmpA(cmd, exec_cmdWA), "server W got wrong command '%s'\n", cmd );
|
|
|
|
else if (!conv_unicode && client_unicode) /* A->W mapping */
|
|
|
|
ok( *(WCHAR *)cmd == exec_cmdW[0], "server W got wrong command '%s'\n", cmd );
|
|
|
|
else
|
|
|
|
ok( !lstrcmpW((LPCWSTR)cmd, exec_cmdW), "server W got wrong command '%s'\n", cmd );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4: /* Unicode command in ANSI format */
|
|
|
|
if (conv_unicode && !client_unicode) /* W->A mapping -> garbage */
|
2011-01-16 15:14:32 +01:00
|
|
|
ok( cmd[0] != exec_cmdWA[0], "server W got wrong command '%s'\n", cmd );
|
2010-06-23 14:19:51 +02:00
|
|
|
else if (!conv_unicode && client_unicode) /* A->W mapping */
|
|
|
|
ok( !lstrcmpW((LPCWSTR)cmd, exec_cmdW), "server W got wrong command '%s'\n", cmd );
|
|
|
|
else
|
|
|
|
ok( !lstrcmpA(cmd, exec_cmdWA), "server W got wrong command '%s'\n", cmd );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
GlobalUnlock((HGLOBAL)hi);
|
|
|
|
}
|
|
|
|
else ok( 0, "bad command data %lx\n", hi );
|
|
|
|
|
|
|
|
step++;
|
|
|
|
trace("server W: posting %s WM_DDE_ACK to %p\n", ack.fAck ? "POSITIVE" : "NEGATIVE", (HWND)wparam);
|
|
|
|
|
|
|
|
status = *((WORD *)&ack);
|
|
|
|
lparam = ReuseDDElParam(lparam, WM_DDE_EXECUTE, WM_DDE_ACK, status, hi);
|
2007-10-08 11:06:08 +02:00
|
|
|
|
2010-06-23 14:19:51 +02:00
|
|
|
PostMessageW((HWND)wparam, WM_DDE_ACK, (WPARAM)hwnd, lparam);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_DDE_TERMINATE:
|
|
|
|
{
|
|
|
|
DDEACK ack;
|
|
|
|
WORD status;
|
|
|
|
|
|
|
|
trace("server W: got WM_DDE_TERMINATE from %p with %08lx\n", (HWND)wparam, lparam);
|
|
|
|
|
|
|
|
ack.bAppReturnCode = 0;
|
|
|
|
ack.reserved = 0;
|
|
|
|
ack.fBusy = 0;
|
|
|
|
ack.fAck = 1;
|
|
|
|
|
|
|
|
trace("server W: posting %s WM_DDE_ACK to %p\n", ack.fAck ? "POSITIVE" : "NEGATIVE", (HWND)wparam);
|
|
|
|
|
|
|
|
status = *((WORD *)&ack);
|
|
|
|
lparam = PackDDElParam(WM_DDE_ACK, status, 0);
|
|
|
|
|
|
|
|
PostMessageW((HWND)wparam, WM_DDE_ACK, (WPARAM)hwnd, lparam);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DefWindowProcW(hwnd, msg, wparam, lparam);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HWND create_dde_server( BOOL unicode )
|
|
|
|
{
|
|
|
|
WNDCLASSA wcA;
|
|
|
|
WNDCLASSW wcW;
|
|
|
|
HWND server;
|
|
|
|
static const char server_class_nameA[] = "dde_server_windowA";
|
|
|
|
static const WCHAR server_class_nameW[] = {'d','d','e','_','s','e','r','v','e','r','_','w','i','n','d','o','w','W',0};
|
|
|
|
|
|
|
|
if (unicode)
|
|
|
|
{
|
|
|
|
memset(&wcW, 0, sizeof(wcW));
|
|
|
|
wcW.lpfnWndProc = dde_server_wndprocW;
|
|
|
|
wcW.lpszClassName = server_class_nameW;
|
|
|
|
wcW.hInstance = GetModuleHandleA(0);
|
|
|
|
RegisterClassW(&wcW);
|
|
|
|
|
|
|
|
server = CreateWindowExW(0, server_class_nameW, NULL, WS_POPUP,
|
|
|
|
100, 100, CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
GetDesktopWindow(), 0, GetModuleHandleA(0), NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
memset(&wcA, 0, sizeof(wcA));
|
|
|
|
wcA.lpfnWndProc = dde_server_wndprocA;
|
|
|
|
wcA.lpszClassName = server_class_nameA;
|
|
|
|
wcA.hInstance = GetModuleHandleA(0);
|
|
|
|
RegisterClassA(&wcA);
|
|
|
|
|
|
|
|
server = CreateWindowExA(0, server_class_nameA, NULL, WS_POPUP,
|
|
|
|
100, 100, CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
GetDesktopWindow(), 0, GetModuleHandleA(0), NULL);
|
|
|
|
}
|
|
|
|
ok(!IsWindowUnicode(server) == !unicode, "wrong unicode type\n");
|
|
|
|
return server;
|
2007-10-08 11:06:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HDDEDATA CALLBACK client_dde_callback(UINT uType, UINT uFmt, HCONV hconv,
|
|
|
|
HSZ hsz1, HSZ hsz2, HDDEDATA hdata,
|
|
|
|
ULONG_PTR dwData1, ULONG_PTR dwData2)
|
|
|
|
{
|
|
|
|
static const char * const cmd_type[15] = {
|
|
|
|
"XTYP_ERROR", "XTYP_ADVDATA", "XTYP_ADVREQ", "XTYP_ADVSTART",
|
|
|
|
"XTYP_ADVSTOP", "XTYP_EXECUTE", "XTYP_CONNECT", "XTYP_CONNECT_CONFIRM",
|
|
|
|
"XTYP_XACT_COMPLETE", "XTYP_POKE", "XTYP_REGISTER", "XTYP_REQUEST",
|
|
|
|
"XTYP_DISCONNECT", "XTYP_UNREGISTER", "XTYP_WILDCONNECT" };
|
|
|
|
UINT type;
|
|
|
|
const char *cmd_name;
|
|
|
|
|
|
|
|
type = (uType & XTYP_MASK) >> XTYP_SHIFT;
|
2007-11-01 17:42:50 +01:00
|
|
|
cmd_name = (type <= 14) ? cmd_type[type] : "unknown";
|
2007-10-08 11:06:08 +02:00
|
|
|
|
|
|
|
trace("client_dde_callback: %04x (%s) %d %p %p %p %p %08lx %08lx\n",
|
|
|
|
uType, cmd_name, uFmt, hconv, hsz1, hsz2, hdata, dwData1, dwData2);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-06-23 14:19:51 +02:00
|
|
|
static void test_dde_aw_transaction( BOOL client_unicode, BOOL server_unicode )
|
2007-10-08 11:06:08 +02:00
|
|
|
{
|
|
|
|
HSZ hsz_server;
|
|
|
|
DWORD dde_inst, ret, err;
|
|
|
|
HCONV hconv;
|
2010-06-23 14:19:51 +02:00
|
|
|
HWND hwnd_server;
|
2007-10-08 11:06:08 +02:00
|
|
|
CONVINFO info;
|
|
|
|
HDDEDATA hdata;
|
2010-06-23 14:19:51 +02:00
|
|
|
BOOL conv_unicode = client_unicode;
|
2011-02-04 17:10:17 +01:00
|
|
|
BOOL got;
|
2007-10-08 11:06:08 +02:00
|
|
|
static char test_cmd[] = "test dde command";
|
|
|
|
|
2010-06-23 14:19:51 +02:00
|
|
|
if (!(hwnd_server = create_dde_server( server_unicode ))) return;
|
2007-10-08 11:06:08 +02:00
|
|
|
|
|
|
|
dde_inst = 0;
|
2010-06-23 14:19:51 +02:00
|
|
|
if (client_unicode)
|
|
|
|
ret = DdeInitializeW(&dde_inst, client_dde_callback, APPCMD_CLIENTONLY, 0);
|
|
|
|
else
|
|
|
|
ret = DdeInitializeA(&dde_inst, client_dde_callback, APPCMD_CLIENTONLY, 0);
|
2008-12-05 17:15:58 +01:00
|
|
|
ok(ret == DMLERR_NO_ERROR, "DdeInitializeA failed with error %04x (%x)\n",
|
2007-10-08 11:06:08 +02:00
|
|
|
ret, DdeGetLastError(dde_inst));
|
|
|
|
|
|
|
|
hsz_server = DdeCreateStringHandleW(dde_inst, TEST_DDE_SERVICE, CP_WINUNICODE);
|
|
|
|
|
|
|
|
hconv = DdeConnect(dde_inst, hsz_server, 0, NULL);
|
|
|
|
ok(hconv != 0, "DdeConnect error %x\n", DdeGetLastError(dde_inst));
|
|
|
|
err = DdeGetLastError(dde_inst);
|
|
|
|
ok(err == DMLERR_NO_ERROR, "wrong dde error %x\n", err);
|
|
|
|
|
|
|
|
info.cb = sizeof(info);
|
|
|
|
ret = DdeQueryConvInfo(hconv, QID_SYNC, &info);
|
|
|
|
ok(ret, "wrong info size %d, DdeQueryConvInfo error %x\n", ret, DdeGetLastError(dde_inst));
|
2010-06-23 14:19:51 +02:00
|
|
|
ok(info.ConvCtxt.iCodePage == client_unicode ? CP_WINUNICODE : CP_WINANSI,
|
|
|
|
"wrong iCodePage %d\n", info.ConvCtxt.iCodePage);
|
2007-10-08 11:06:08 +02:00
|
|
|
ok(!info.hConvPartner, "unexpected info.hConvPartner: %p\n", info.hConvPartner);
|
|
|
|
todo_wine {
|
|
|
|
ok((info.wStatus & DDE_FACK), "unexpected info.wStatus: %04x\n", info.wStatus);
|
|
|
|
}
|
|
|
|
ok((info.wStatus & (ST_CONNECTED | ST_CLIENT)) == (ST_CONNECTED | ST_CLIENT), "unexpected info.wStatus: %04x\n", info.wStatus);
|
|
|
|
ok(info.wConvst == XST_CONNECTED, "unexpected info.wConvst: %04x\n", info.wConvst);
|
|
|
|
ok(info.wType == 0, "unexpected info.wType: %04x\n", info.wType);
|
|
|
|
|
2010-06-23 14:19:51 +02:00
|
|
|
client_unicode = IsWindowUnicode( info.hwnd );
|
|
|
|
trace("hwnd %p, hwndPartner %p, unicode %u\n", info.hwnd, info.hwndPartner, client_unicode);
|
2007-10-08 11:06:08 +02:00
|
|
|
|
|
|
|
trace("sending test client transaction command\n");
|
|
|
|
ret = 0xdeadbeef;
|
|
|
|
hdata = DdeClientTransaction((LPBYTE)test_cmd, strlen(test_cmd) + 1, hconv, (HSZ)0xdead, 0xbeef, XTYP_EXECUTE, 1000, &ret);
|
|
|
|
ok(!hdata, "DdeClientTransaction succeeded\n");
|
2010-06-24 23:36:24 +02:00
|
|
|
ok(ret == DDE_FNOTPROCESSED || broken(ret == (0xdead0000 | DDE_FNOTPROCESSED)), /* win9x */
|
|
|
|
"wrong status code %04x\n", ret);
|
2007-10-08 11:06:08 +02:00
|
|
|
err = DdeGetLastError(dde_inst);
|
|
|
|
ok(err == DMLERR_NOTPROCESSED, "wrong dde error %x\n", err);
|
|
|
|
|
|
|
|
trace("sending ANSI client transaction command\n");
|
|
|
|
ret = 0xdeadbeef;
|
|
|
|
hdata = DdeClientTransaction((LPBYTE)exec_cmdA, lstrlenA(exec_cmdA) + 1, hconv, 0, 0, XTYP_EXECUTE, 1000, &ret);
|
2010-06-23 14:19:51 +02:00
|
|
|
err = DdeGetLastError(dde_inst);
|
|
|
|
if (conv_unicode && (!client_unicode || !server_unicode)) /* W->A mapping -> garbage */
|
|
|
|
{
|
|
|
|
ok(!hdata, "DdeClientTransaction returned %p, error %x\n", hdata, err);
|
|
|
|
ok(ret == DDE_FNOTPROCESSED, "wrong status code %04x\n", ret);
|
|
|
|
ok(err == DMLERR_NOTPROCESSED, "DdeClientTransaction returned error %x\n", err);
|
|
|
|
}
|
|
|
|
else if (!conv_unicode && client_unicode && server_unicode) /* A->W mapping -> wrong cmd */
|
|
|
|
{
|
|
|
|
ok(!hdata, "DdeClientTransaction returned %p, error %x\n", hdata, err);
|
|
|
|
ok(ret == DDE_FNOTPROCESSED, "wrong status code %04x\n", ret);
|
|
|
|
ok(err == DMLERR_NOTPROCESSED, "DdeClientTransaction returned error %x\n", err);
|
|
|
|
}
|
|
|
|
else /* no mapping */
|
|
|
|
{
|
|
|
|
ok(hdata != 0, "DdeClientTransaction returned %p, error %x\n", hdata, err);
|
|
|
|
ok(ret == DDE_FACK, "wrong status code %04x\n", ret);
|
|
|
|
ok(err == DMLERR_NO_ERROR, "wrong dde error %x\n", err);
|
|
|
|
}
|
2007-10-08 11:06:08 +02:00
|
|
|
|
2010-06-23 14:19:51 +02:00
|
|
|
trace("sending ANSI-as-Unicode client transaction command\n");
|
|
|
|
ret = 0xdeadbeef;
|
|
|
|
hdata = DdeClientTransaction((LPBYTE)exec_cmdAW, (lstrlenW(exec_cmdAW) + 1) * sizeof(WCHAR),
|
|
|
|
hconv, 0, 0, XTYP_EXECUTE, 1000, &ret);
|
2007-10-08 11:06:08 +02:00
|
|
|
err = DdeGetLastError(dde_inst);
|
2010-06-23 14:19:51 +02:00
|
|
|
if (conv_unicode && (!client_unicode || !server_unicode)) /* W->A mapping */
|
|
|
|
{
|
|
|
|
ok(hdata != 0, "DdeClientTransaction returned %p, error %x\n", hdata, err);
|
|
|
|
ok(ret == DDE_FACK, "wrong status code %04x\n", ret);
|
|
|
|
ok(err == DMLERR_NO_ERROR, "wrong dde error %x\n", err);
|
|
|
|
}
|
|
|
|
else if (!conv_unicode && client_unicode && server_unicode) /* A->W mapping -> garbage */
|
|
|
|
{
|
|
|
|
ok(!hdata, "DdeClientTransaction returned %p, error %x\n", hdata, err);
|
|
|
|
ok(ret == DDE_FNOTPROCESSED, "wrong status code %04x\n", ret);
|
|
|
|
ok(err == DMLERR_NOTPROCESSED, "DdeClientTransaction returned error %x\n", err);
|
|
|
|
}
|
|
|
|
else /* no mapping */
|
|
|
|
{
|
|
|
|
ok(!hdata, "DdeClientTransaction returned %p, error %x\n", hdata, err);
|
2010-06-24 23:36:24 +02:00
|
|
|
ok(ret == DDE_FNOTPROCESSED || broken(ret == (0xdead0000 | DDE_FNOTPROCESSED)), /* win9x */
|
|
|
|
"wrong status code %04x\n", ret);
|
2010-06-23 14:19:51 +02:00
|
|
|
ok(err == DMLERR_NOTPROCESSED, "DdeClientTransaction returned error %x\n", err);
|
|
|
|
}
|
2007-10-08 11:06:08 +02:00
|
|
|
|
|
|
|
trace("sending unicode client transaction command\n");
|
|
|
|
ret = 0xdeadbeef;
|
|
|
|
hdata = DdeClientTransaction((LPBYTE)exec_cmdW, (lstrlenW(exec_cmdW) + 1) * sizeof(WCHAR), hconv, 0, 0, XTYP_EXECUTE, 1000, &ret);
|
|
|
|
err = DdeGetLastError(dde_inst);
|
2010-06-23 14:19:51 +02:00
|
|
|
if (conv_unicode && (!client_unicode || !server_unicode)) /* W->A mapping -> wrong cmd */
|
|
|
|
{
|
|
|
|
ok(!hdata, "DdeClientTransaction returned %p, error %x\n", hdata, err);
|
|
|
|
ok(ret == DDE_FNOTPROCESSED, "wrong status code %04x\n", ret);
|
|
|
|
ok(err == DMLERR_NOTPROCESSED, "DdeClientTransaction returned error %x\n", err);
|
|
|
|
}
|
|
|
|
else if (!conv_unicode && client_unicode && server_unicode) /* A->W mapping -> garbage */
|
|
|
|
{
|
|
|
|
ok(!hdata, "DdeClientTransaction returned %p, error %x\n", hdata, err);
|
|
|
|
ok(ret == DDE_FNOTPROCESSED, "wrong status code %04x\n", ret);
|
|
|
|
ok(err == DMLERR_NOTPROCESSED, "DdeClientTransaction returned error %x\n", err);
|
|
|
|
}
|
|
|
|
else /* no mapping */
|
|
|
|
{
|
|
|
|
ok(hdata != 0, "DdeClientTransaction returned %p, error %x\n", hdata, err);
|
|
|
|
ok(ret == DDE_FACK, "wrong status code %04x\n", ret);
|
|
|
|
ok(err == DMLERR_NO_ERROR, "wrong dde error %x\n", err);
|
|
|
|
}
|
|
|
|
|
|
|
|
trace("sending Unicode-as-ANSI client transaction command\n");
|
|
|
|
ret = 0xdeadbeef;
|
|
|
|
hdata = DdeClientTransaction((LPBYTE)exec_cmdWA, lstrlenA(exec_cmdWA) + 1, hconv, 0, 0, XTYP_EXECUTE, 1000, &ret);
|
|
|
|
err = DdeGetLastError(dde_inst);
|
|
|
|
if (conv_unicode && (!client_unicode || !server_unicode)) /* W->A mapping -> garbage */
|
|
|
|
{
|
|
|
|
ok(!hdata, "DdeClientTransaction returned %p, error %x\n", hdata, err);
|
|
|
|
ok(ret == DDE_FNOTPROCESSED, "wrong status code %04x\n", ret);
|
|
|
|
ok(err == DMLERR_NOTPROCESSED, "DdeClientTransaction returned error %x\n", err);
|
|
|
|
}
|
|
|
|
else if (!conv_unicode && client_unicode && server_unicode) /* A->W mapping */
|
|
|
|
{
|
|
|
|
ok(hdata != 0, "DdeClientTransaction returned %p, error %x\n", hdata, err);
|
|
|
|
ok(ret == DDE_FACK, "wrong status code %04x\n", ret);
|
|
|
|
ok(err == DMLERR_NO_ERROR, "wrong dde error %x\n", err);
|
|
|
|
}
|
|
|
|
else /* no mapping */
|
|
|
|
{
|
|
|
|
ok(!hdata, "DdeClientTransaction returned %p, error %x\n", hdata, err);
|
|
|
|
ok(ret == DDE_FNOTPROCESSED, "wrong status code %04x\n", ret);
|
|
|
|
ok(err == DMLERR_NOTPROCESSED, "DdeClientTransaction returned error %x\n", err);
|
|
|
|
}
|
2007-10-08 11:06:08 +02:00
|
|
|
|
2011-02-04 17:10:17 +01:00
|
|
|
got = DdeDisconnect(hconv);
|
|
|
|
ok(got, "DdeDisconnect error %x\n", DdeGetLastError(dde_inst));
|
2007-10-08 11:06:08 +02:00
|
|
|
|
|
|
|
info.cb = sizeof(info);
|
|
|
|
ret = DdeQueryConvInfo(hconv, QID_SYNC, &info);
|
|
|
|
ok(!ret, "DdeQueryConvInfo should fail\n");
|
|
|
|
err = DdeGetLastError(dde_inst);
|
|
|
|
todo_wine {
|
|
|
|
ok(err == DMLERR_INVALIDPARAMETER, "wrong dde error %x\n", err);
|
|
|
|
}
|
|
|
|
|
2011-02-04 17:10:17 +01:00
|
|
|
got = DdeFreeStringHandle(dde_inst, hsz_server);
|
|
|
|
ok(got, "DdeFreeStringHandle error %x\n", DdeGetLastError(dde_inst));
|
2007-10-08 11:06:08 +02:00
|
|
|
|
|
|
|
/* This call hangs on win2k SP4 and XP SP1.
|
|
|
|
DdeUninitialize(dde_inst);*/
|
|
|
|
|
|
|
|
DestroyWindow(hwnd_server);
|
2007-10-04 07:28:45 +02:00
|
|
|
}
|
|
|
|
|
2008-08-05 14:18:27 +02:00
|
|
|
static void test_initialisation(void)
|
|
|
|
{
|
|
|
|
UINT ret;
|
|
|
|
DWORD res;
|
|
|
|
HDDEDATA hdata;
|
|
|
|
HSZ server, topic, item;
|
|
|
|
DWORD client_pid;
|
|
|
|
HCONV conversation;
|
|
|
|
|
|
|
|
/* Initialise without a valid server window. */
|
|
|
|
client_pid = 0;
|
|
|
|
ret = DdeInitializeA(&client_pid, client_ddeml_callback, APPCMD_CLIENTONLY, 0);
|
|
|
|
ok(ret == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", ret);
|
|
|
|
|
|
|
|
|
|
|
|
server = DdeCreateStringHandleA(client_pid, "TestDDEService", CP_WINANSI);
|
|
|
|
topic = DdeCreateStringHandleA(client_pid, "TestDDETopic", CP_WINANSI);
|
|
|
|
|
|
|
|
DdeGetLastError(client_pid);
|
|
|
|
|
|
|
|
/* There is no server window so no conversation can be extracted */
|
|
|
|
conversation = DdeConnect(client_pid, server, topic, NULL);
|
|
|
|
ok(conversation == NULL, "Expected NULL conversation, %p\n", conversation);
|
|
|
|
ret = DdeGetLastError(client_pid);
|
|
|
|
ok(ret == DMLERR_NO_CONV_ESTABLISHED, "Expected DMLERR_NO_CONV_ESTABLISHED, got %d\n", ret);
|
|
|
|
|
|
|
|
DdeFreeStringHandle(client_pid, server);
|
|
|
|
|
|
|
|
item = DdeCreateStringHandleA(client_pid, "request", CP_WINANSI);
|
|
|
|
|
|
|
|
/* There is no converstation so an invalild parameter results */
|
|
|
|
res = 0xdeadbeef;
|
|
|
|
DdeGetLastError(client_pid);
|
|
|
|
hdata = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_REQUEST, default_timeout, &res);
|
2010-05-22 10:17:37 +02:00
|
|
|
ok(hdata == NULL, "Expected NULL, got %p\n", hdata);
|
2008-08-05 14:18:27 +02:00
|
|
|
ret = DdeGetLastError(client_pid);
|
|
|
|
todo_wine
|
|
|
|
ok(ret == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", ret);
|
|
|
|
ok(res == 0xdeadbeef, "Expected 0xdeadbeef, got %08x\n", res);
|
|
|
|
|
|
|
|
DdeFreeStringHandle(client_pid, server);
|
|
|
|
ret = DdeDisconnect(conversation);
|
|
|
|
ok(ret == FALSE, "Expected FALSE, got %d\n", ret);
|
|
|
|
|
|
|
|
ret = DdeUninitialize(client_pid);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
}
|
|
|
|
|
2004-04-23 23:32:17 +02:00
|
|
|
static void test_DdeCreateStringHandleW(DWORD dde_inst, int codepage)
|
|
|
|
{
|
|
|
|
static const WCHAR dde_string[] = {'D','D','E',' ','S','t','r','i','n','g',0};
|
|
|
|
HSZ str_handle;
|
|
|
|
WCHAR bufW[256];
|
|
|
|
char buf[256];
|
2007-09-20 06:37:49 +02:00
|
|
|
ATOM atom;
|
2004-04-23 23:32:17 +02:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
str_handle = DdeCreateStringHandleW(dde_inst, dde_string, codepage);
|
|
|
|
ok(str_handle != 0, "DdeCreateStringHandleW failed with error %08x\n",
|
|
|
|
DdeGetLastError(dde_inst));
|
|
|
|
|
|
|
|
ret = DdeQueryStringW(dde_inst, str_handle, NULL, 0, codepage);
|
|
|
|
if (codepage == CP_WINANSI)
|
|
|
|
ok(ret == 1, "DdeQueryStringW returned wrong length %d\n", ret);
|
|
|
|
else
|
|
|
|
ok(ret == lstrlenW(dde_string), "DdeQueryStringW returned wrong length %d\n", ret);
|
|
|
|
|
|
|
|
ret = DdeQueryStringW(dde_inst, str_handle, bufW, 256, codepage);
|
|
|
|
if (codepage == CP_WINANSI)
|
|
|
|
{
|
|
|
|
ok(ret == 1, "DdeQueryStringW returned wrong length %d\n", ret);
|
|
|
|
ok(!lstrcmpA("D", (LPCSTR)bufW), "DdeQueryStringW returned wrong string\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(ret == lstrlenW(dde_string), "DdeQueryStringW returned wrong length %d\n", ret);
|
|
|
|
ok(!lstrcmpW(dde_string, bufW), "DdeQueryStringW returned wrong string\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = DdeQueryStringA(dde_inst, str_handle, buf, 256, CP_WINANSI);
|
|
|
|
if (codepage == CP_WINANSI)
|
|
|
|
{
|
|
|
|
ok(ret == 1, "DdeQueryStringA returned wrong length %d\n", ret);
|
|
|
|
ok(!lstrcmpA("D", buf), "DdeQueryStringW returned wrong string\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(ret == lstrlenA("DDE String"), "DdeQueryStringA returned wrong length %d\n", ret);
|
|
|
|
ok(!lstrcmpA("DDE String", buf), "DdeQueryStringA returned wrong string %s\n", buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = DdeQueryStringA(dde_inst, str_handle, buf, 256, CP_WINUNICODE);
|
|
|
|
if (codepage == CP_WINANSI)
|
|
|
|
{
|
|
|
|
ok(ret == 1, "DdeQueryStringA returned wrong length %d\n", ret);
|
|
|
|
ok(!lstrcmpA("D", buf), "DdeQueryStringA returned wrong string %s\n", buf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(ret == lstrlenA("DDE String"), "DdeQueryStringA returned wrong length %d\n", ret);
|
|
|
|
ok(!lstrcmpW(dde_string, (LPCWSTR)buf), "DdeQueryStringW returned wrong string\n");
|
|
|
|
}
|
|
|
|
|
2007-09-20 06:37:49 +02:00
|
|
|
if (codepage == CP_WINANSI)
|
|
|
|
{
|
|
|
|
atom = FindAtomA((LPSTR)dde_string);
|
|
|
|
ok(atom != 0, "Expected a valid atom\n");
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
atom = GlobalFindAtomA((LPSTR)dde_string);
|
|
|
|
ok(atom == 0, "Expected 0, got %d\n", atom);
|
|
|
|
ok(GetLastError() == ERROR_FILE_NOT_FOUND,
|
|
|
|
"Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
atom = FindAtomW(dde_string);
|
|
|
|
ok(atom != 0, "Expected a valid atom\n");
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
atom = GlobalFindAtomW(dde_string);
|
|
|
|
ok(atom == 0, "Expected 0, got %d\n", atom);
|
|
|
|
ok(GetLastError() == ERROR_FILE_NOT_FOUND,
|
|
|
|
"Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
|
|
|
|
}
|
|
|
|
|
2004-04-23 23:32:17 +02:00
|
|
|
ok(DdeFreeStringHandle(dde_inst, str_handle), "DdeFreeStringHandle failed\n");
|
|
|
|
}
|
|
|
|
|
2007-10-12 07:22:54 +02:00
|
|
|
static void test_DdeCreateDataHandle(void)
|
|
|
|
{
|
|
|
|
HDDEDATA hdata;
|
2009-01-22 13:35:27 +01:00
|
|
|
DWORD dde_inst, dde_inst2;
|
2007-10-12 07:22:54 +02:00
|
|
|
DWORD size;
|
|
|
|
UINT res, err;
|
|
|
|
BOOL ret;
|
|
|
|
HSZ item;
|
|
|
|
LPBYTE ptr;
|
2009-01-24 11:34:35 +01:00
|
|
|
WCHAR item_str[] = {'i','t','e','m',0};
|
2007-10-12 07:22:54 +02:00
|
|
|
|
|
|
|
dde_inst = 0;
|
2009-01-22 13:35:27 +01:00
|
|
|
dde_inst2 = 0;
|
2007-10-12 07:22:54 +02:00
|
|
|
res = DdeInitializeA(&dde_inst, client_ddeml_callback, APPCMD_CLIENTONLY, 0);
|
|
|
|
ok(res == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", res);
|
|
|
|
|
2009-01-22 13:35:27 +01:00
|
|
|
res = DdeInitializeA(&dde_inst2, client_ddeml_callback, APPCMD_CLIENTONLY, 0);
|
|
|
|
ok(res == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", res);
|
|
|
|
|
2009-01-24 11:34:35 +01:00
|
|
|
/* 0 instance id
|
|
|
|
* This block tests an invalid instance Id. The correct behaviour is that if the instance Id
|
|
|
|
* is invalid then the lastError of all instances is set to the error. There are two instances
|
|
|
|
* created, lastError is cleared, an error is generated and then both instances are checked to
|
|
|
|
* ensure that they both have the same error set
|
|
|
|
*/
|
|
|
|
item = DdeCreateStringHandleA(0, "item", CP_WINANSI);
|
|
|
|
ok(item == NULL, "Expected NULL hsz got %p\n", item);
|
|
|
|
err = DdeGetLastError(dde_inst);
|
|
|
|
ok(err == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", err);
|
|
|
|
err = DdeGetLastError(dde_inst2);
|
|
|
|
ok(err == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", err);
|
|
|
|
item = DdeCreateStringHandleW(0, item_str, CP_WINUNICODE);
|
|
|
|
ok(item == NULL, "Expected NULL hsz got %p\n", item);
|
|
|
|
err = DdeGetLastError(dde_inst);
|
|
|
|
ok(err == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", err);
|
|
|
|
err = DdeGetLastError(dde_inst2);
|
|
|
|
ok(err == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", err);
|
|
|
|
|
2007-10-12 07:22:54 +02:00
|
|
|
item = DdeCreateStringHandleA(dde_inst, "item", CP_WINANSI);
|
|
|
|
ok(item != NULL, "Expected non-NULL hsz\n");
|
2009-01-22 13:35:27 +01:00
|
|
|
item = DdeCreateStringHandleA(dde_inst2, "item", CP_WINANSI);
|
|
|
|
ok(item != NULL, "Expected non-NULL hsz\n");
|
2007-10-12 07:22:54 +02:00
|
|
|
|
2008-11-05 21:30:41 +01:00
|
|
|
if (0) {
|
|
|
|
/* do not test with an invalid instance id: that crashes on win9x */
|
|
|
|
hdata = DdeCreateDataHandle(0xdeadbeef, (LPBYTE)"data", MAX_PATH, 0, item, CF_TEXT, 0);
|
2007-10-12 07:22:54 +02:00
|
|
|
}
|
|
|
|
|
2009-01-22 13:35:27 +01:00
|
|
|
/* 0 instance id
|
|
|
|
* This block tests an invalid instance Id. The correct behaviour is that if the instance Id
|
|
|
|
* is invalid then the lastError of all instances is set to the error. There are two instances
|
|
|
|
* created, lastError is cleared, an error is generated and then both instances are checked to
|
|
|
|
* ensure that they both have the same error set
|
|
|
|
*/
|
2007-10-12 07:22:54 +02:00
|
|
|
DdeGetLastError(dde_inst);
|
2009-01-22 13:35:27 +01:00
|
|
|
DdeGetLastError(dde_inst2);
|
2007-10-12 07:22:54 +02:00
|
|
|
hdata = DdeCreateDataHandle(0, (LPBYTE)"data", MAX_PATH, 0, item, CF_TEXT, 0);
|
|
|
|
err = DdeGetLastError(dde_inst);
|
2009-01-22 13:35:27 +01:00
|
|
|
ok(hdata == NULL, "Expected NULL, got %p\n", hdata);
|
|
|
|
ok(err == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", err);
|
|
|
|
err = DdeGetLastError(dde_inst2);
|
|
|
|
ok(err == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", err);
|
|
|
|
|
|
|
|
ret = DdeUninitialize(dde_inst2);
|
|
|
|
ok(res == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", res);
|
|
|
|
|
2007-10-12 07:22:54 +02:00
|
|
|
|
|
|
|
/* NULL pSrc */
|
|
|
|
DdeGetLastError(dde_inst);
|
|
|
|
hdata = DdeCreateDataHandle(dde_inst, NULL, MAX_PATH, 0, item, CF_TEXT, 0);
|
|
|
|
err = DdeGetLastError(dde_inst);
|
|
|
|
ok(hdata != NULL, "Expected non-NULL hdata\n");
|
|
|
|
ok(err == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", err);
|
|
|
|
|
|
|
|
ptr = DdeAccessData(hdata, &size);
|
|
|
|
ok(ptr != NULL, "Expected non-NULL ptr\n");
|
|
|
|
ok(size == 260, "Expected 260, got %d\n", size);
|
|
|
|
|
|
|
|
ret = DdeUnaccessData(hdata);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
|
|
|
|
ret = DdeFreeDataHandle(hdata);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
|
|
|
|
/* cb is zero */
|
|
|
|
DdeGetLastError(dde_inst);
|
|
|
|
hdata = DdeCreateDataHandle(dde_inst, (LPBYTE)"data", 0, 0, item, CF_TEXT, 0);
|
|
|
|
err = DdeGetLastError(dde_inst);
|
|
|
|
ok(hdata != NULL, "Expected non-NULL hdata\n");
|
|
|
|
ok(err == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", err);
|
|
|
|
|
|
|
|
ptr = DdeAccessData(hdata, &size);
|
|
|
|
ok(ptr != NULL, "Expected non-NULL ptr\n");
|
|
|
|
ok(size == 0, "Expected 0, got %d\n", size);
|
|
|
|
|
|
|
|
ret = DdeUnaccessData(hdata);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
|
|
|
|
ret = DdeFreeDataHandle(hdata);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
|
|
|
|
/* cbOff is non-zero */
|
|
|
|
DdeGetLastError(dde_inst);
|
|
|
|
hdata = DdeCreateDataHandle(dde_inst, (LPBYTE)"data", MAX_PATH, 2, item, CF_TEXT, 0);
|
|
|
|
err = DdeGetLastError(dde_inst);
|
|
|
|
ok(hdata != NULL, "Expected non-NULL hdata\n");
|
|
|
|
ok(err == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", err);
|
|
|
|
|
|
|
|
ptr = DdeAccessData(hdata, &size);
|
|
|
|
ok(ptr != NULL, "Expected non-NULL ptr\n");
|
|
|
|
ok(size == 262, "Expected 262, got %d\n", size);
|
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
ok(lstrlenA((LPSTR)ptr) == 0, "Expected 0, got %d\n", lstrlenA((LPSTR)ptr));
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = DdeUnaccessData(hdata);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
|
|
|
|
ret = DdeFreeDataHandle(hdata);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
|
|
|
|
/* NULL item */
|
|
|
|
DdeGetLastError(dde_inst);
|
|
|
|
hdata = DdeCreateDataHandle(dde_inst, (LPBYTE)"data", MAX_PATH, 0, 0, CF_TEXT, 0);
|
|
|
|
err = DdeGetLastError(dde_inst);
|
|
|
|
ok(hdata != NULL, "Expected non-NULL hdata\n");
|
|
|
|
ok(err == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", err);
|
|
|
|
|
|
|
|
ptr = DdeAccessData(hdata, &size);
|
|
|
|
ok(ptr != NULL, "Expected non-NULL ptr\n");
|
|
|
|
ok(!lstrcmpA((LPSTR)ptr, "data"), "Expected data, got %s\n", ptr);
|
|
|
|
ok(size == 260, "Expected 260, got %d\n", size);
|
|
|
|
|
|
|
|
ret = DdeUnaccessData(hdata);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
|
|
|
|
ret = DdeFreeDataHandle(hdata);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
|
|
|
|
/* NULL item */
|
|
|
|
DdeGetLastError(dde_inst);
|
|
|
|
hdata = DdeCreateDataHandle(dde_inst, (LPBYTE)"data", MAX_PATH, 0, (HSZ)0xdeadbeef, CF_TEXT, 0);
|
|
|
|
err = DdeGetLastError(dde_inst);
|
|
|
|
ok(hdata != NULL, "Expected non-NULL hdata\n");
|
|
|
|
ok(err == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", err);
|
|
|
|
|
|
|
|
ptr = DdeAccessData(hdata, &size);
|
|
|
|
ok(ptr != NULL, "Expected non-NULL ptr\n");
|
|
|
|
ok(!lstrcmpA((LPSTR)ptr, "data"), "Expected data, got %s\n", ptr);
|
|
|
|
ok(size == 260, "Expected 260, got %d\n", size);
|
|
|
|
|
|
|
|
ret = DdeUnaccessData(hdata);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
|
|
|
|
ret = DdeFreeDataHandle(hdata);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
|
|
|
|
/* invalid clipboard format */
|
|
|
|
DdeGetLastError(dde_inst);
|
|
|
|
hdata = DdeCreateDataHandle(dde_inst, (LPBYTE)"data", MAX_PATH, 0, item, 0xdeadbeef, 0);
|
|
|
|
err = DdeGetLastError(dde_inst);
|
|
|
|
ok(hdata != NULL, "Expected non-NULL hdata\n");
|
|
|
|
ok(err == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", err);
|
|
|
|
|
|
|
|
ptr = DdeAccessData(hdata, &size);
|
|
|
|
ok(ptr != NULL, "Expected non-NULL ptr\n");
|
|
|
|
ok(!lstrcmpA((LPSTR)ptr, "data"), "Expected data, got %s\n", ptr);
|
|
|
|
ok(size == 260, "Expected 260, got %d\n", size);
|
|
|
|
|
|
|
|
ret = DdeUnaccessData(hdata);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
|
|
|
|
ret = DdeFreeDataHandle(hdata);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
|
|
|
|
ret = DdeUninitialize(dde_inst);
|
|
|
|
ok(res == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", res);
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:33:09 +02:00
|
|
|
static void test_DdeCreateStringHandle(void)
|
2004-04-23 23:32:17 +02:00
|
|
|
{
|
|
|
|
DWORD dde_inst, ret;
|
|
|
|
|
|
|
|
dde_inst = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
2007-10-04 07:28:45 +02:00
|
|
|
ret = DdeInitializeW(&dde_inst, client_ddeml_callback, APPCMD_CLIENTONLY, 0);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(ret == DMLERR_INVALIDPARAMETER, "DdeInitializeW should fail, but got %04x instead\n", ret);
|
2004-04-23 23:32:17 +02:00
|
|
|
ok(DdeGetLastError(dde_inst) == DMLERR_INVALIDPARAMETER, "expected DMLERR_INVALIDPARAMETER\n");
|
|
|
|
|
|
|
|
dde_inst = 0;
|
2007-10-04 07:28:45 +02:00
|
|
|
ret = DdeInitializeW(&dde_inst, client_ddeml_callback, APPCMD_CLIENTONLY, 0);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(ret == DMLERR_NO_ERROR, "DdeInitializeW failed with error %04x (%08x)\n",
|
2004-04-23 23:32:17 +02:00
|
|
|
ret, DdeGetLastError(dde_inst));
|
|
|
|
|
|
|
|
test_DdeCreateStringHandleW(dde_inst, 0);
|
|
|
|
test_DdeCreateStringHandleW(dde_inst, CP_WINUNICODE);
|
|
|
|
test_DdeCreateStringHandleW(dde_inst, CP_WINANSI);
|
|
|
|
|
|
|
|
ok(DdeUninitialize(dde_inst), "DdeUninitialize failed\n");
|
|
|
|
}
|
2005-07-08 13:33:09 +02:00
|
|
|
|
2007-09-17 01:26:07 +02:00
|
|
|
static void test_FreeDDElParam(void)
|
|
|
|
{
|
|
|
|
HGLOBAL val, hglobal;
|
|
|
|
BOOL ret;
|
|
|
|
|
2008-11-02 00:23:27 +01:00
|
|
|
ret = FreeDDElParam(WM_DDE_INITIATE, 0);
|
2007-09-17 01:26:07 +02:00
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
|
|
|
|
hglobal = GlobalAlloc(GMEM_DDESHARE, 100);
|
|
|
|
ret = FreeDDElParam(WM_DDE_INITIATE, (LPARAM)hglobal);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
val = GlobalFree(hglobal);
|
|
|
|
ok(val == NULL, "Expected NULL, got %p\n", val);
|
|
|
|
|
|
|
|
hglobal = GlobalAlloc(GMEM_DDESHARE, 100);
|
|
|
|
ret = FreeDDElParam(WM_DDE_ADVISE, (LPARAM)hglobal);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
|
|
|
|
hglobal = GlobalAlloc(GMEM_DDESHARE, 100);
|
|
|
|
ret = FreeDDElParam(WM_DDE_UNADVISE, (LPARAM)hglobal);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
val = GlobalFree(hglobal);
|
|
|
|
ok(val == NULL, "Expected NULL, got %p\n", val);
|
|
|
|
|
|
|
|
hglobal = GlobalAlloc(GMEM_DDESHARE, 100);
|
|
|
|
ret = FreeDDElParam(WM_DDE_ACK, (LPARAM)hglobal);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
|
|
|
|
hglobal = GlobalAlloc(GMEM_DDESHARE, 100);
|
|
|
|
ret = FreeDDElParam(WM_DDE_DATA, (LPARAM)hglobal);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
|
|
|
|
hglobal = GlobalAlloc(GMEM_DDESHARE, 100);
|
|
|
|
ret = FreeDDElParam(WM_DDE_REQUEST, (LPARAM)hglobal);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
val = GlobalFree(hglobal);
|
|
|
|
ok(val == NULL, "Expected NULL, got %p\n", val);
|
|
|
|
|
|
|
|
hglobal = GlobalAlloc(GMEM_DDESHARE, 100);
|
|
|
|
ret = FreeDDElParam(WM_DDE_POKE, (LPARAM)hglobal);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
|
|
|
|
hglobal = GlobalAlloc(GMEM_DDESHARE, 100);
|
|
|
|
ret = FreeDDElParam(WM_DDE_EXECUTE, (LPARAM)hglobal);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
val = GlobalFree(hglobal);
|
|
|
|
ok(val == NULL, "Expected NULL, got %p\n", val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_PackDDElParam(void)
|
|
|
|
{
|
|
|
|
UINT_PTR lo, hi, *ptr;
|
|
|
|
LPARAM lparam;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
lparam = PackDDElParam(WM_DDE_INITIATE, 0xcafe, 0xbeef);
|
2009-01-10 21:06:49 +01:00
|
|
|
/* value gets sign-extended despite being an LPARAM */
|
|
|
|
ok(lparam == (int)0xbeefcafe, "Expected 0xbeefcafe, got %08lx\n", lparam);
|
2007-09-17 01:26:07 +02:00
|
|
|
|
|
|
|
lo = hi = 0;
|
|
|
|
ret = UnpackDDElParam(WM_DDE_INITIATE, lparam, &lo, &hi);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
ok(lo == 0xcafe, "Expected 0xcafe, got %08lx\n", lo);
|
|
|
|
ok(hi == 0xbeef, "Expected 0xbeef, got %08lx\n", hi);
|
|
|
|
|
|
|
|
ret = FreeDDElParam(WM_DDE_INITIATE, lparam);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
|
|
|
|
lparam = PackDDElParam(WM_DDE_TERMINATE, 0xcafe, 0xbeef);
|
2009-01-10 21:06:49 +01:00
|
|
|
ok(lparam == (int)0xbeefcafe, "Expected 0xbeefcafe, got %08lx\n", lparam);
|
2007-09-17 01:26:07 +02:00
|
|
|
|
|
|
|
lo = hi = 0;
|
|
|
|
ret = UnpackDDElParam(WM_DDE_TERMINATE, lparam, &lo, &hi);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
ok(lo == 0xcafe, "Expected 0xcafe, got %08lx\n", lo);
|
|
|
|
ok(hi == 0xbeef, "Expected 0xbeef, got %08lx\n", hi);
|
|
|
|
|
|
|
|
ret = FreeDDElParam(WM_DDE_TERMINATE, lparam);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
|
|
|
|
lparam = PackDDElParam(WM_DDE_ADVISE, 0xcafe, 0xbeef);
|
2008-11-05 21:30:41 +01:00
|
|
|
/* win9x returns 0 here */
|
|
|
|
if (lparam) {
|
|
|
|
ptr = GlobalLock((HGLOBAL)lparam);
|
|
|
|
ok(ptr != NULL, "Expected non-NULL ptr\n");
|
|
|
|
ok(ptr[0] == 0xcafe, "Expected 0xcafe, got %08lx\n", ptr[0]);
|
|
|
|
ok(ptr[1] == 0xbeef, "Expected 0xbeef, got %08lx\n", ptr[1]);
|
2007-09-17 01:26:07 +02:00
|
|
|
|
2008-11-05 21:30:41 +01:00
|
|
|
ret = GlobalUnlock((HGLOBAL)lparam);
|
|
|
|
ok(ret == 1, "Expected 1, got %d\n", ret);
|
2007-09-17 01:26:07 +02:00
|
|
|
|
2008-11-05 21:30:41 +01:00
|
|
|
lo = hi = 0;
|
|
|
|
ret = UnpackDDElParam(WM_DDE_ADVISE, lparam, &lo, &hi);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
ok(lo == 0xcafe, "Expected 0xcafe, got %08lx\n", lo);
|
|
|
|
ok(hi == 0xbeef, "Expected 0xbeef, got %08lx\n", hi);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("no lparam for WM_DDE_ADVISE\n");
|
2007-09-17 01:26:07 +02:00
|
|
|
|
|
|
|
ret = FreeDDElParam(WM_DDE_ADVISE, lparam);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
|
|
|
|
lparam = PackDDElParam(WM_DDE_UNADVISE, 0xcafe, 0xbeef);
|
2009-01-10 21:06:49 +01:00
|
|
|
ok(lparam == (int)0xbeefcafe, "Expected 0xbeefcafe, got %08lx\n", lparam);
|
2007-09-17 01:26:07 +02:00
|
|
|
|
|
|
|
lo = hi = 0;
|
|
|
|
ret = UnpackDDElParam(WM_DDE_UNADVISE, lparam, &lo, &hi);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
ok(lo == 0xcafe, "Expected 0xcafe, got %08lx\n", lo);
|
|
|
|
ok(hi == 0xbeef, "Expected 0xbeef, got %08lx\n", hi);
|
|
|
|
|
|
|
|
ret = FreeDDElParam(WM_DDE_UNADVISE, lparam);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
|
|
|
|
lparam = PackDDElParam(WM_DDE_ACK, 0xcafe, 0xbeef);
|
2008-11-05 21:30:41 +01:00
|
|
|
/* win9x returns the input (0xbeef<<16 | 0xcafe) here */
|
2009-01-10 21:06:49 +01:00
|
|
|
if (lparam != (int)0xbeefcafe) {
|
2008-11-05 21:30:41 +01:00
|
|
|
ptr = GlobalLock((HGLOBAL)lparam);
|
|
|
|
ok(ptr != NULL, "Expected non-NULL ptr\n");
|
|
|
|
ok(ptr[0] == 0xcafe, "Expected 0xcafe, got %08lx\n", ptr[0]);
|
|
|
|
ok(ptr[1] == 0xbeef, "Expected 0xbeef, got %08lx\n", ptr[1]);
|
2007-09-17 01:26:07 +02:00
|
|
|
|
2008-11-05 21:30:41 +01:00
|
|
|
ret = GlobalUnlock((HGLOBAL)lparam);
|
|
|
|
ok(ret == 1, "Expected 1, got %d\n", ret);
|
2007-09-17 01:26:07 +02:00
|
|
|
|
2008-11-05 21:30:41 +01:00
|
|
|
lo = hi = 0;
|
|
|
|
ret = UnpackDDElParam(WM_DDE_ACK, lparam, &lo, &hi);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
ok(lo == 0xcafe, "Expected 0xcafe, got %08lx\n", lo);
|
|
|
|
ok(hi == 0xbeef, "Expected 0xbeef, got %08lx\n", hi);
|
2007-09-17 01:26:07 +02:00
|
|
|
|
2008-11-05 21:30:41 +01:00
|
|
|
ret = FreeDDElParam(WM_DDE_ACK, lparam);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("got lparam 0x%lx for WM_DDE_ACK\n", lparam);
|
2007-09-17 01:26:07 +02:00
|
|
|
|
|
|
|
lparam = PackDDElParam(WM_DDE_DATA, 0xcafe, 0xbeef);
|
2008-11-05 21:30:41 +01:00
|
|
|
/* win9x returns 0 here */
|
|
|
|
if (lparam) {
|
|
|
|
ptr = GlobalLock((HGLOBAL)lparam);
|
|
|
|
ok(ptr != NULL, "Expected non-NULL ptr\n");
|
|
|
|
ok(ptr[0] == 0xcafe, "Expected 0xcafe, got %08lx\n", ptr[0]);
|
|
|
|
ok(ptr[1] == 0xbeef, "Expected 0xbeef, got %08lx\n", ptr[1]);
|
2007-09-17 01:26:07 +02:00
|
|
|
|
2008-11-05 21:30:41 +01:00
|
|
|
ret = GlobalUnlock((HGLOBAL)lparam);
|
|
|
|
ok(ret == 1, "Expected 1, got %d\n", ret);
|
2007-09-17 01:26:07 +02:00
|
|
|
|
2008-11-05 21:30:41 +01:00
|
|
|
lo = hi = 0;
|
|
|
|
ret = UnpackDDElParam(WM_DDE_DATA, lparam, &lo, &hi);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
ok(lo == 0xcafe, "Expected 0xcafe, got %08lx\n", lo);
|
|
|
|
ok(hi == 0xbeef, "Expected 0xbeef, got %08lx\n", hi);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("no lparam for WM_DDE_DATA\n");
|
2007-09-17 01:26:07 +02:00
|
|
|
|
|
|
|
ret = FreeDDElParam(WM_DDE_DATA, lparam);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
|
|
|
|
lparam = PackDDElParam(WM_DDE_REQUEST, 0xcafe, 0xbeef);
|
2009-01-10 21:06:49 +01:00
|
|
|
ok(lparam == (int)0xbeefcafe, "Expected 0xbeefcafe, got %08lx\n", lparam);
|
2007-09-17 01:26:07 +02:00
|
|
|
|
|
|
|
lo = hi = 0;
|
|
|
|
ret = UnpackDDElParam(WM_DDE_REQUEST, lparam, &lo, &hi);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
ok(lo == 0xcafe, "Expected 0xcafe, got %08lx\n", lo);
|
|
|
|
ok(hi == 0xbeef, "Expected 0xbeef, got %08lx\n", hi);
|
|
|
|
|
|
|
|
ret = FreeDDElParam(WM_DDE_REQUEST, lparam);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
|
|
|
|
lparam = PackDDElParam(WM_DDE_POKE, 0xcafe, 0xbeef);
|
2008-11-05 21:30:41 +01:00
|
|
|
/* win9x returns 0 here */
|
|
|
|
if (lparam) {
|
|
|
|
ptr = GlobalLock((HGLOBAL)lparam);
|
|
|
|
ok(ptr != NULL, "Expected non-NULL ptr\n");
|
|
|
|
ok(ptr[0] == 0xcafe, "Expected 0xcafe, got %08lx\n", ptr[0]);
|
|
|
|
ok(ptr[1] == 0xbeef, "Expected 0xbeef, got %08lx\n", ptr[1]);
|
2007-09-17 01:26:07 +02:00
|
|
|
|
2008-11-05 21:30:41 +01:00
|
|
|
ret = GlobalUnlock((HGLOBAL)lparam);
|
|
|
|
ok(ret == 1, "Expected 1, got %d\n", ret);
|
2007-09-17 01:26:07 +02:00
|
|
|
|
2008-11-05 21:30:41 +01:00
|
|
|
lo = hi = 0;
|
|
|
|
ret = UnpackDDElParam(WM_DDE_POKE, lparam, &lo, &hi);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
ok(lo == 0xcafe, "Expected 0xcafe, got %08lx\n", lo);
|
|
|
|
ok(hi == 0xbeef, "Expected 0xbeef, got %08lx\n", hi);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("no lparam for WM_DDE_POKE\n");
|
2007-09-17 01:26:07 +02:00
|
|
|
|
|
|
|
ret = FreeDDElParam(WM_DDE_POKE, lparam);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
|
|
|
|
lparam = PackDDElParam(WM_DDE_EXECUTE, 0xcafe, 0xbeef);
|
|
|
|
ok(lparam == 0xbeef, "Expected 0xbeef, got %08lx\n", lparam);
|
|
|
|
|
|
|
|
lo = hi = 0;
|
|
|
|
ret = UnpackDDElParam(WM_DDE_EXECUTE, lparam, &lo, &hi);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
ok(lo == 0, "Expected 0, got %08lx\n", lo);
|
|
|
|
ok(hi == 0xbeef, "Expected 0xbeef, got %08lx\n", hi);
|
|
|
|
|
|
|
|
ret = FreeDDElParam(WM_DDE_EXECUTE, lparam);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_UnpackDDElParam(void)
|
|
|
|
{
|
|
|
|
UINT_PTR lo, hi, *ptr;
|
|
|
|
HGLOBAL hglobal;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
/* NULL lParam */
|
|
|
|
lo = 0xdead;
|
|
|
|
hi = 0xbeef;
|
2008-11-02 00:23:27 +01:00
|
|
|
ret = UnpackDDElParam(WM_DDE_INITIATE, 0, &lo, &hi);
|
2007-09-17 01:26:07 +02:00
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
ok(lo == 0, "Expected 0, got %08lx\n", lo);
|
|
|
|
ok(hi == 0, "Expected 0, got %08lx\n", hi);
|
|
|
|
|
|
|
|
/* NULL lo */
|
|
|
|
lo = 0xdead;
|
|
|
|
hi = 0xbeef;
|
|
|
|
ret = UnpackDDElParam(WM_DDE_INITIATE, 0xcafebabe, NULL, &hi);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
ok(lo == 0xdead, "Expected 0xdead, got %08lx\n", lo);
|
|
|
|
ok(hi == 0xcafe, "Expected 0xcafe, got %08lx\n", hi);
|
|
|
|
|
|
|
|
/* NULL hi */
|
|
|
|
lo = 0xdead;
|
|
|
|
hi = 0xbeef;
|
|
|
|
ret = UnpackDDElParam(WM_DDE_INITIATE, 0xcafebabe, &lo, NULL);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
ok(lo == 0xbabe, "Expected 0xbabe, got %08lx\n", lo);
|
|
|
|
ok(hi == 0xbeef, "Expected 0xbeef, got %08lx\n", hi);
|
|
|
|
|
|
|
|
lo = 0xdead;
|
|
|
|
hi = 0xbeef;
|
|
|
|
ret = UnpackDDElParam(WM_DDE_INITIATE, 0xcafebabe, &lo, &hi);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
ok(lo == 0xbabe, "Expected 0xbabe, got %08lx\n", lo);
|
|
|
|
ok(hi == 0xcafe, "Expected 0xcafe, got %08lx\n", hi);
|
|
|
|
|
|
|
|
lo = 0xdead;
|
|
|
|
hi = 0xbeef;
|
|
|
|
ret = UnpackDDElParam(WM_DDE_TERMINATE, 0xcafebabe, &lo, &hi);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
ok(lo == 0xbabe, "Expected 0xbabe, got %08lx\n", lo);
|
|
|
|
ok(hi == 0xcafe, "Expected 0xcafe, got %08lx\n", hi);
|
|
|
|
|
|
|
|
lo = 0xdead;
|
|
|
|
hi = 0xbeef;
|
2008-11-02 00:23:27 +01:00
|
|
|
ret = UnpackDDElParam(WM_DDE_ADVISE, 0, &lo, &hi);
|
2007-09-17 01:26:07 +02:00
|
|
|
ok(ret == FALSE, "Expected FALSE, got %d\n", ret);
|
2008-07-01 07:53:30 +02:00
|
|
|
ok(lo == 0 ||
|
|
|
|
broken(lo == 0xdead), /* win2k */
|
|
|
|
"Expected 0, got %08lx\n", lo);
|
|
|
|
ok(hi == 0 ||
|
|
|
|
broken(hi == 0xbeef), /* win2k */
|
|
|
|
"Expected 0, got %08lx\n", hi);
|
2007-09-17 01:26:07 +02:00
|
|
|
|
2009-12-02 20:02:09 +01:00
|
|
|
hglobal = GlobalAlloc(GMEM_DDESHARE, 2 * sizeof(*ptr));
|
2007-09-17 01:26:07 +02:00
|
|
|
ptr = GlobalLock(hglobal);
|
|
|
|
ptr[0] = 0xcafebabe;
|
|
|
|
ptr[1] = 0xdeadbeef;
|
|
|
|
GlobalUnlock(hglobal);
|
|
|
|
|
|
|
|
lo = 0xdead;
|
|
|
|
hi = 0xbeef;
|
|
|
|
ret = UnpackDDElParam(WM_DDE_ADVISE, (LPARAM)hglobal, &lo, &hi);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
ok(lo == 0xcafebabe, "Expected 0xcafebabe, got %08lx\n", lo);
|
|
|
|
ok(hi == 0xdeadbeef, "Expected 0xdeadbeef, got %08lx\n", hi);
|
|
|
|
|
|
|
|
lo = 0xdead;
|
|
|
|
hi = 0xbeef;
|
|
|
|
ret = UnpackDDElParam(WM_DDE_UNADVISE, 0xcafebabe, &lo, &hi);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
ok(lo == 0xbabe, "Expected 0xbabe, got %08lx\n", lo);
|
|
|
|
ok(hi == 0xcafe, "Expected 0xcafe, got %08lx\n", hi);
|
|
|
|
|
|
|
|
lo = 0xdead;
|
|
|
|
hi = 0xbeef;
|
|
|
|
ret = UnpackDDElParam(WM_DDE_ACK, (LPARAM)hglobal, &lo, &hi);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
ok(lo == 0xcafebabe, "Expected 0xcafebabe, got %08lx\n", lo);
|
|
|
|
ok(hi == 0xdeadbeef, "Expected 0xdeadbeef, got %08lx\n", hi);
|
|
|
|
|
|
|
|
lo = 0xdead;
|
|
|
|
hi = 0xbeef;
|
|
|
|
ret = UnpackDDElParam(WM_DDE_DATA, (LPARAM)hglobal, &lo, &hi);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
ok(lo == 0xcafebabe, "Expected 0xcafebabe, got %08lx\n", lo);
|
|
|
|
ok(hi == 0xdeadbeef, "Expected 0xdeadbeef, got %08lx\n", hi);
|
|
|
|
|
|
|
|
lo = 0xdead;
|
|
|
|
hi = 0xbeef;
|
|
|
|
ret = UnpackDDElParam(WM_DDE_REQUEST, 0xcafebabe, &lo, &hi);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
ok(lo == 0xbabe, "Expected 0xbabe, got %08lx\n", lo);
|
|
|
|
ok(hi == 0xcafe, "Expected 0xcafe, got %08lx\n", hi);
|
|
|
|
|
|
|
|
lo = 0xdead;
|
|
|
|
hi = 0xbeef;
|
|
|
|
ret = UnpackDDElParam(WM_DDE_POKE, (LPARAM)hglobal, &lo, &hi);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
ok(lo == 0xcafebabe, "Expected 0xcafebabe, got %08lx\n", lo);
|
|
|
|
ok(hi == 0xdeadbeef, "Expected 0xdeadbeef, got %08lx\n", hi);
|
|
|
|
|
|
|
|
lo = 0xdead;
|
|
|
|
hi = 0xbeef;
|
|
|
|
ret = UnpackDDElParam(WM_DDE_EXECUTE, 0xcafebabe, &lo, &hi);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
ok(lo == 0, "Expected 0, got %08lx\n", lo);
|
|
|
|
ok(hi == 0xcafebabe, "Expected 0xcafebabe, got %08lx\n", hi);
|
2009-11-29 00:18:59 +01:00
|
|
|
|
|
|
|
GlobalFree(hglobal);
|
2007-09-17 01:26:07 +02:00
|
|
|
}
|
|
|
|
|
2010-06-24 19:56:49 +02:00
|
|
|
static char test_cmd_a_to_a[] = "Test dde command";
|
|
|
|
static WCHAR test_cmd_w_to_w[][32] = {
|
|
|
|
{'t','e','s','t',' ','d','d','e',' ','c','o','m','m','a','n','d',0},
|
2010-06-24 21:27:45 +02:00
|
|
|
{ 0x2018, 0x2019, 0x0161, 0x0041, 0x02dc, 0 }, /* some chars that should map properly to CP1252 */
|
|
|
|
{ 0x2026, 0x2020, 0x2021, 0x0d0a, 0 }, /* false negative for IsTextUnicode */
|
|
|
|
{ 0x4efa, 0x4efc, 0x0061, 0x4efe, 0 }, /* some Chinese chars */
|
2010-06-24 19:56:49 +02:00
|
|
|
};
|
|
|
|
static const int nb_callbacks = 5 + sizeof(test_cmd_w_to_w)/sizeof(test_cmd_w_to_w[0]);
|
|
|
|
|
2008-09-04 13:07:36 +02:00
|
|
|
static HDDEDATA CALLBACK server_end_to_end_callback(UINT uType, UINT uFmt, HCONV hconv,
|
|
|
|
HSZ hsz1, HSZ hsz2, HDDEDATA hdata,
|
|
|
|
ULONG_PTR dwData1, ULONG_PTR dwData2)
|
|
|
|
{
|
|
|
|
DWORD size, rsize;
|
|
|
|
char str[MAX_PATH];
|
|
|
|
static int msg_index = 0;
|
|
|
|
static HCONV conversation = 0;
|
|
|
|
static char test_service [] = "TestDDEService";
|
|
|
|
static char test_topic [] = "TestDDETopic";
|
|
|
|
|
|
|
|
msg_index++;
|
|
|
|
|
|
|
|
switch (uType)
|
|
|
|
{
|
|
|
|
case XTYP_REGISTER:
|
|
|
|
{
|
2010-06-24 19:56:49 +02:00
|
|
|
ok(msg_index % nb_callbacks == 1, "Expected 1 modulo %u, got %d\n", nb_callbacks, msg_index);
|
2008-09-04 13:07:36 +02:00
|
|
|
return (HDDEDATA)TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
case XTYP_CONNECT:
|
|
|
|
{
|
2010-06-24 19:56:49 +02:00
|
|
|
ok(msg_index % nb_callbacks == 2, "Expected 2 modulo %u, got %d\n", nb_callbacks, msg_index);
|
2008-09-04 13:07:36 +02:00
|
|
|
ok(uFmt == 0, "Expected 0, got %d, msg_index=%d\n", uFmt, msg_index);
|
|
|
|
ok(hconv == 0, "Expected 0, got %p, msg_index=%d\n", hconv, msg_index);
|
|
|
|
ok(hdata == 0, "Expected 0, got %p, msg_index=%d\n", hdata, msg_index);
|
|
|
|
ok(dwData1 != 0, "Expected not 0, got %08lx, msg_index=%d\n", dwData1, msg_index);
|
|
|
|
ok(dwData2 == FALSE, "Expected FALSE, got %08lx, msg_index=%d\n", dwData2, msg_index);
|
|
|
|
|
|
|
|
size = DdeQueryStringA(server_pid, hsz1, str, MAX_PATH, CP_WINANSI);
|
|
|
|
ok(!lstrcmpA(str, test_topic), "Expected %s, got %s, msg_index=%d\n",
|
|
|
|
test_topic, str, msg_index);
|
|
|
|
ok(size == 12, "Expected 12, got %d, msg_index=%d\n", size, msg_index);
|
|
|
|
|
|
|
|
size = DdeQueryStringA(server_pid, hsz2, str, MAX_PATH, CP_WINANSI);
|
|
|
|
ok(!lstrcmpA(str, test_service), "Expected %s, got %s, msg_index=%d\n",
|
|
|
|
test_service, str, msg_index);
|
|
|
|
ok(size == 14, "Expected 14, got %d, msg_index=%d\n", size, msg_index);
|
|
|
|
|
|
|
|
return (HDDEDATA) TRUE;
|
|
|
|
}
|
|
|
|
case XTYP_CONNECT_CONFIRM:
|
|
|
|
{
|
2010-06-24 19:56:49 +02:00
|
|
|
ok(msg_index % nb_callbacks == 3, "Expected 3 modulo %u, got %d\n", nb_callbacks, msg_index);
|
2008-09-04 13:07:36 +02:00
|
|
|
conversation = hconv;
|
|
|
|
return (HDDEDATA) TRUE;
|
|
|
|
}
|
|
|
|
case XTYP_EXECUTE:
|
|
|
|
{
|
|
|
|
BYTE *buffer = NULL;
|
2010-06-24 19:56:49 +02:00
|
|
|
WCHAR *cmd_w;
|
|
|
|
char test_cmd_w_to_a[64];
|
|
|
|
WCHAR test_cmd_a_to_w[64];
|
|
|
|
DWORD size_a, size_w, size_w_to_a, size_a_to_w;
|
|
|
|
BOOL unicode_server, unicode_client, str_index;
|
2008-09-04 13:07:36 +02:00
|
|
|
|
|
|
|
ok(uFmt == 0, "Expected 0, got %d\n", uFmt);
|
|
|
|
ok(hconv == conversation, "Expected conversation handle, got %p, msg_index=%d\n",
|
|
|
|
hconv, msg_index);
|
|
|
|
ok(dwData1 == 0, "Expected 0, got %08lx, msg_index=%d\n", dwData1, msg_index);
|
|
|
|
ok(dwData2 == 0, "Expected 0, got %08lx, msg_index=%d\n", dwData2, msg_index);
|
|
|
|
ok(hsz2 == 0, "Expected 0, got %p, msg_index=%d\n", hsz2, msg_index);
|
|
|
|
size = DdeQueryStringA(server_pid, hsz1, str, MAX_PATH, CP_WINANSI);
|
|
|
|
ok(!lstrcmpA(str, test_topic), "Expected %s, got %s, msg_index=%d\n",
|
|
|
|
test_topic, str, msg_index);
|
|
|
|
ok(size == 12, "Expected 12, got %d, msg_index=%d\n", size, msg_index);
|
|
|
|
ok(size == 12, "Expected 12, got %d, msg_index=%d\n", size, msg_index);
|
|
|
|
|
|
|
|
size = DdeGetData(hdata, NULL, 0, 0);
|
|
|
|
ok((buffer = HeapAlloc(GetProcessHeap(), 0, size)) != NULL, "should not be null\n");
|
|
|
|
rsize = DdeGetData(hdata, buffer, size, 0);
|
2010-06-24 19:56:49 +02:00
|
|
|
ok(rsize == size, "Incorrect size returned, expected %d got %d, msg_index=%d\n",
|
|
|
|
size, rsize, msg_index);
|
|
|
|
trace("msg %u strA \"%s\" strW %s\n", msg_index, buffer, wine_dbgstr_w((WCHAR*)buffer));
|
|
|
|
|
|
|
|
unicode_server = (msg_index / nb_callbacks == 1 || msg_index / nb_callbacks == 2);
|
|
|
|
unicode_client = (msg_index / nb_callbacks == 1 || msg_index / nb_callbacks == 3);
|
|
|
|
str_index = msg_index % nb_callbacks - 4;
|
|
|
|
cmd_w = test_cmd_w_to_w[str_index - 1];
|
|
|
|
size_a = strlen(test_cmd_a_to_a) + 1;
|
|
|
|
size_w = (lstrlenW(cmd_w) + 1) * sizeof(WCHAR);
|
|
|
|
size_a_to_w = MultiByteToWideChar( CP_ACP, 0, test_cmd_a_to_a, -1, test_cmd_a_to_w,
|
|
|
|
sizeof(test_cmd_a_to_w)/sizeof(WCHAR) ) * sizeof(WCHAR);
|
|
|
|
size_w_to_a = WideCharToMultiByte( CP_ACP, 0, cmd_w, -1,
|
|
|
|
test_cmd_w_to_a, sizeof(test_cmd_w_to_a), NULL, NULL );
|
|
|
|
switch (str_index)
|
2008-09-04 13:08:53 +02:00
|
|
|
{
|
2010-06-24 19:56:49 +02:00
|
|
|
case 0: /* ASCII string */
|
|
|
|
if (unicode_server)
|
|
|
|
{
|
|
|
|
ok(size == size_a_to_w, "Wrong size %d/%d, msg_index=%d\n", size, size_a_to_w, msg_index);
|
|
|
|
ok(!lstrcmpW((WCHAR*)buffer, test_cmd_a_to_w),
|
|
|
|
"Expected %s, msg_index=%d\n", wine_dbgstr_w(test_cmd_a_to_w), msg_index);
|
|
|
|
}
|
|
|
|
else if (unicode_client)
|
|
|
|
{
|
|
|
|
/* ASCII string mapped W->A -> garbage */
|
|
|
|
}
|
2009-01-16 01:40:31 +01:00
|
|
|
else
|
|
|
|
{
|
2010-06-24 19:56:49 +02:00
|
|
|
ok(size == size_a, "Wrong size %d/%d, msg_index=%d\n", size, size_a, msg_index);
|
|
|
|
ok(!lstrcmpA((CHAR*)buffer, test_cmd_a_to_a), "Expected %s, got %s, msg_index=%d\n",
|
|
|
|
test_cmd_a_to_a, buffer, msg_index);
|
2009-01-16 01:40:31 +01:00
|
|
|
}
|
2010-06-24 19:56:49 +02:00
|
|
|
break;
|
2008-09-04 13:08:53 +02:00
|
|
|
|
2010-06-24 19:56:49 +02:00
|
|
|
case 1: /* Unicode string with only 8-bit chars */
|
|
|
|
if (unicode_server)
|
|
|
|
{
|
|
|
|
ok(size == size_w, "Wrong size %d/%d, msg_index=%d\n", size, size_w, msg_index);
|
|
|
|
ok(!lstrcmpW((WCHAR*)buffer, cmd_w),
|
|
|
|
"Expected %s, msg_index=%d\n", wine_dbgstr_w(cmd_w), msg_index);
|
|
|
|
}
|
|
|
|
else if (unicode_client)
|
|
|
|
{
|
|
|
|
ok(size == size_w_to_a, "Wrong size %d/%d, msg_index=%d\n", size, size_w_to_a, msg_index);
|
|
|
|
ok(!lstrcmpA((CHAR*)buffer, test_cmd_w_to_a), "Expected %s, got %s, msg_index=%d\n",
|
|
|
|
test_cmd_w_to_a, buffer, msg_index);
|
|
|
|
}
|
2010-06-24 23:43:08 +02:00
|
|
|
else
|
2010-06-24 19:56:49 +02:00
|
|
|
{
|
|
|
|
ok(size == size_w_to_a, "Wrong size %d/%d, msg_index=%d\n",
|
|
|
|
size, size_w_to_a, msg_index);
|
|
|
|
ok(!lstrcmpA((CHAR*)buffer, test_cmd_w_to_a), "Expected %s, got %s, msg_index=%d\n",
|
|
|
|
test_cmd_w_to_a, buffer, msg_index);
|
|
|
|
}
|
|
|
|
break;
|
2008-09-04 13:07:36 +02:00
|
|
|
|
2010-06-24 21:27:45 +02:00
|
|
|
case 2: /* normal Unicode string */
|
|
|
|
case 3: /* IsTextUnicode false negative */
|
|
|
|
case 4: /* Chinese chars */
|
2010-06-24 23:43:08 +02:00
|
|
|
if (unicode_server)
|
2010-06-24 21:27:45 +02:00
|
|
|
{
|
|
|
|
/* double A->W mapping */
|
|
|
|
/* NT uses the full size, XP+ only until the first null */
|
|
|
|
DWORD nt_size = MultiByteToWideChar( CP_ACP, 0, (char *)cmd_w, size_w, test_cmd_a_to_w,
|
|
|
|
sizeof(test_cmd_a_to_w)/sizeof(WCHAR) ) * sizeof(WCHAR);
|
|
|
|
DWORD xp_size = MultiByteToWideChar( CP_ACP, 0, (char *)cmd_w, -1, NULL, 0 ) * sizeof(WCHAR);
|
2011-01-16 15:14:32 +01:00
|
|
|
ok(size == xp_size || broken(size == nt_size) ||
|
|
|
|
broken(str_index == 4 && IsDBCSLeadByte(cmd_w[0])) /* East Asian */,
|
2010-06-24 21:27:45 +02:00
|
|
|
"Wrong size %d/%d, msg_index=%d\n", size, size_a_to_w, msg_index);
|
|
|
|
ok(!lstrcmpW((WCHAR*)buffer, test_cmd_a_to_w),
|
|
|
|
"Expected %s, msg_index=%d\n", wine_dbgstr_w(test_cmd_a_to_w), msg_index);
|
|
|
|
}
|
|
|
|
else if (unicode_client)
|
|
|
|
{
|
|
|
|
ok(size == size_w_to_a, "Wrong size %d/%d, msg_index=%d\n", size, size_w_to_a, msg_index);
|
|
|
|
ok(!lstrcmpA((CHAR*)buffer, test_cmd_w_to_a), "Expected %s, got %s, msg_index=%d\n",
|
|
|
|
test_cmd_w_to_a, buffer, msg_index);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(size == size_w, "Wrong size %d/%d, msg_index=%d\n", size, size_w, msg_index);
|
|
|
|
ok(!lstrcmpW((WCHAR*)buffer, cmd_w),
|
|
|
|
"Expected %s, msg_index=%d\n", wine_dbgstr_w(cmd_w), msg_index);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-06-24 19:56:49 +02:00
|
|
|
default:
|
|
|
|
ok( 0, "Invalid message %u\n", msg_index );
|
|
|
|
break;
|
|
|
|
}
|
2008-09-04 13:07:36 +02:00
|
|
|
return (HDDEDATA) DDE_FACK;
|
|
|
|
}
|
|
|
|
case XTYP_DISCONNECT:
|
|
|
|
return (HDDEDATA) TRUE;
|
|
|
|
|
|
|
|
default:
|
|
|
|
ok(FALSE, "Unhandled msg: %08x, msg_index=%d\n", uType, msg_index);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HDDEDATA CALLBACK client_end_to_end_callback(UINT uType, UINT uFmt, HCONV hconv,
|
|
|
|
HSZ hsz1, HSZ hsz2, HDDEDATA hdata,
|
|
|
|
ULONG_PTR dwData1, ULONG_PTR dwData2)
|
|
|
|
{
|
|
|
|
switch (uType)
|
|
|
|
{
|
|
|
|
case XTYP_DISCONNECT:
|
|
|
|
return (HDDEDATA) TRUE;
|
|
|
|
|
|
|
|
default:
|
|
|
|
ok(FALSE, "Unhandled msg: %08x\n", uType);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_end_to_end_client(BOOL type_a)
|
|
|
|
{
|
2010-06-24 19:56:49 +02:00
|
|
|
DWORD i, ret, err;
|
2008-09-04 13:07:36 +02:00
|
|
|
DWORD client_pid = 0;
|
|
|
|
HSZ server, topic;
|
|
|
|
HCONV hconv;
|
|
|
|
HDDEDATA hdata;
|
|
|
|
static char test_service[] = "TestDDEService";
|
|
|
|
static WCHAR test_service_w[] = {'T','e','s','t','D','D','E','S','e','r','v','i','c','e',0};
|
|
|
|
static char test_topic[] = "TestDDETopic";
|
|
|
|
static WCHAR test_topic_w[] = {'T','e','s','t','D','D','E','T','o','p','i','c',0};
|
|
|
|
|
2009-01-16 01:40:31 +01:00
|
|
|
trace("Start end to end client %s\n", type_a ? "ASCII" : "UNICODE");
|
2008-09-04 13:07:36 +02:00
|
|
|
|
|
|
|
if (type_a)
|
|
|
|
ret = DdeInitializeA(&client_pid, client_end_to_end_callback, APPCMD_CLIENTONLY, 0);
|
|
|
|
else
|
|
|
|
ret = DdeInitializeW(&client_pid, client_end_to_end_callback, APPCMD_CLIENTONLY, 0);
|
|
|
|
ok(ret == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %x\n", ret);
|
|
|
|
|
|
|
|
if (type_a)
|
|
|
|
{
|
|
|
|
server = DdeCreateStringHandleA(client_pid, test_service, CP_WINANSI);
|
|
|
|
topic = DdeCreateStringHandleA(client_pid, test_topic, CP_WINANSI);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
server = DdeCreateStringHandleW(client_pid, test_service_w, CP_WINUNICODE);
|
|
|
|
topic = DdeCreateStringHandleW(client_pid, test_topic_w, CP_WINUNICODE);
|
|
|
|
}
|
|
|
|
|
|
|
|
DdeGetLastError(client_pid);
|
|
|
|
hconv = DdeConnect(client_pid, server, topic, NULL);
|
|
|
|
ok(hconv != NULL, "Expected non-NULL conversation\n");
|
|
|
|
ret = DdeGetLastError(client_pid);
|
|
|
|
ok(ret == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %x\n", ret);
|
|
|
|
DdeFreeStringHandle(client_pid, server);
|
|
|
|
|
2008-09-04 13:08:46 +02:00
|
|
|
/* Test both A and W data being passed to DdeClientTransaction */
|
2010-06-24 19:56:49 +02:00
|
|
|
hdata = DdeClientTransaction((LPBYTE)test_cmd_a_to_a, sizeof(test_cmd_a_to_a),
|
2008-09-04 13:07:36 +02:00
|
|
|
hconv, (HSZ)0xdead, 0xbeef, XTYP_EXECUTE, 1000, &ret);
|
|
|
|
ok(hdata != NULL, "DdeClientTransaction failed\n");
|
|
|
|
ok(ret == DDE_FACK, "wrong status code %x\n", ret);
|
|
|
|
err = DdeGetLastError(client_pid);
|
|
|
|
ok(err == DMLERR_NO_ERROR, "wrong dde error %x\n", err);
|
|
|
|
|
2010-06-24 19:56:49 +02:00
|
|
|
for (i = 0; i < sizeof(test_cmd_w_to_w)/sizeof(test_cmd_w_to_w[0]); i++)
|
|
|
|
{
|
|
|
|
hdata = DdeClientTransaction((LPBYTE)test_cmd_w_to_w[i],
|
|
|
|
(lstrlenW(test_cmd_w_to_w[i]) + 1) * sizeof(WCHAR),
|
|
|
|
hconv, (HSZ)0xdead, 0xbeef, XTYP_EXECUTE, 1000, &ret);
|
|
|
|
ok(hdata != NULL, "DdeClientTransaction failed\n");
|
|
|
|
ok(ret == DDE_FACK, "wrong status code %x\n", ret);
|
|
|
|
err = DdeGetLastError(client_pid);
|
|
|
|
ok(err == DMLERR_NO_ERROR, "wrong dde error %x\n", err);
|
|
|
|
}
|
2008-09-04 13:08:46 +02:00
|
|
|
|
2008-09-04 13:07:36 +02:00
|
|
|
DdeFreeStringHandle(client_pid, topic);
|
|
|
|
ret = DdeDisconnect(hconv);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %x\n", ret);
|
|
|
|
|
|
|
|
ret = DdeUninitialize(client_pid);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %x\n", ret);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_end_to_end_server(HANDLE hproc, HANDLE hthread, BOOL type_a)
|
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
HSZ server;
|
|
|
|
BOOL ret;
|
|
|
|
DWORD res;
|
|
|
|
HDDEDATA hdata;
|
|
|
|
static CHAR test_service[] = "TestDDEService";
|
|
|
|
|
2009-01-16 01:40:31 +01:00
|
|
|
trace("start end to end server %s\n", type_a ? "ASCII" : "UNICODE");
|
2008-09-04 13:07:36 +02:00
|
|
|
server_pid = 0;
|
|
|
|
|
|
|
|
if (type_a)
|
|
|
|
res = DdeInitializeA(&server_pid, server_end_to_end_callback, APPCLASS_STANDARD, 0);
|
|
|
|
else
|
|
|
|
res = DdeInitializeW(&server_pid, server_end_to_end_callback, APPCLASS_STANDARD, 0);
|
|
|
|
ok(res == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", res);
|
|
|
|
|
|
|
|
server = DdeCreateStringHandleA(server_pid, test_service, CP_WINANSI);
|
|
|
|
ok(server != NULL, "Expected non-NULL string handle\n");
|
|
|
|
|
|
|
|
hdata = DdeNameService(server_pid, server, 0, DNS_REGISTER);
|
|
|
|
ok(hdata == (HDDEDATA)TRUE, "Expected TRUE, got %p\n", hdata);
|
|
|
|
ResumeThread( hthread );
|
|
|
|
|
|
|
|
|
|
|
|
while (MsgWaitForMultipleObjects( 1, &hproc, FALSE, INFINITE, QS_ALLINPUT ) != 0)
|
|
|
|
{
|
|
|
|
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = DdeUninitialize(server_pid);
|
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
GetExitCodeProcess( hproc, &res );
|
|
|
|
ok( !res, "client failed with %u error(s)\n", res );
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:33:09 +02:00
|
|
|
START_TEST(dde)
|
|
|
|
{
|
2007-10-04 07:28:45 +02:00
|
|
|
int argc;
|
|
|
|
char **argv;
|
|
|
|
char buffer[MAX_PATH];
|
|
|
|
STARTUPINFO startup;
|
|
|
|
PROCESS_INFORMATION proc;
|
2010-11-30 18:51:57 +01:00
|
|
|
DWORD dde_inst = 0xdeadbeef;
|
2007-10-04 07:28:45 +02:00
|
|
|
|
|
|
|
argc = winetest_get_mainargs(&argv);
|
|
|
|
if (argc == 3)
|
|
|
|
{
|
|
|
|
if (!lstrcmpA(argv[2], "ddeml"))
|
|
|
|
test_ddeml_client();
|
2007-10-08 11:06:45 +02:00
|
|
|
else if (!lstrcmpA(argv[2], "msg"))
|
|
|
|
test_msg_client();
|
2008-09-04 13:07:36 +02:00
|
|
|
else if (!lstrcmpA(argv[2], "enda"))
|
|
|
|
test_end_to_end_client(TRUE);
|
2008-09-04 13:08:46 +02:00
|
|
|
else if (!lstrcmpA(argv[2], "endw"))
|
|
|
|
test_end_to_end_client(FALSE);
|
2007-10-04 07:28:45 +02:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-08-05 14:18:27 +02:00
|
|
|
test_initialisation();
|
|
|
|
|
2010-11-30 18:51:57 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
DdeInitializeW(&dde_inst, client_ddeml_callback, APPCMD_CLIENTONLY, 0);
|
|
|
|
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
{
|
|
|
|
win_skip("Skipping tests on win9x because of brokenness\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-10-04 07:28:45 +02:00
|
|
|
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,
|
2008-06-02 14:13:01 +02:00
|
|
|
CREATE_SUSPENDED, NULL, NULL, &startup, &proc);
|
2007-10-04 07:28:45 +02:00
|
|
|
|
2008-06-02 14:13:01 +02:00
|
|
|
test_msg_server(proc.hProcess, proc.hThread);
|
2007-10-04 07:28:45 +02:00
|
|
|
|
2007-10-08 11:06:45 +02:00
|
|
|
sprintf(buffer, "%s dde msg", argv[0]);
|
|
|
|
CreateProcessA(NULL, buffer, NULL, NULL, FALSE,
|
|
|
|
0, NULL, NULL, &startup, &proc);
|
|
|
|
|
|
|
|
test_ddeml_server(proc.hProcess);
|
|
|
|
|
2008-09-04 13:07:36 +02:00
|
|
|
/* Test the combinations of A and W interfaces with A and W data
|
|
|
|
end to end to ensure that data conversions are accurate */
|
|
|
|
sprintf(buffer, "%s dde enda", argv[0]);
|
|
|
|
CreateProcessA(NULL, buffer, NULL, NULL, FALSE,
|
|
|
|
CREATE_SUSPENDED, NULL, NULL, &startup, &proc);
|
|
|
|
|
|
|
|
test_end_to_end_server(proc.hProcess, proc.hThread, TRUE);
|
|
|
|
|
2009-10-08 11:25:20 +02:00
|
|
|
/* Don't bother testing W interfaces on Win9x/WinMe */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
lstrcmpW(NULL, NULL);
|
|
|
|
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
{
|
|
|
|
win_skip("Skipping W-interface tests\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprintf(buffer, "%s dde endw", argv[0]);
|
|
|
|
CreateProcessA(NULL, buffer, NULL, NULL, FALSE,
|
|
|
|
CREATE_SUSPENDED, NULL, NULL, &startup, &proc);
|
2008-09-04 13:08:46 +02:00
|
|
|
|
2009-10-08 11:25:20 +02:00
|
|
|
test_end_to_end_server(proc.hProcess, proc.hThread, FALSE);
|
2008-09-04 13:08:46 +02:00
|
|
|
|
2009-10-08 11:25:20 +02:00
|
|
|
sprintf(buffer, "%s dde enda", argv[0]);
|
|
|
|
CreateProcessA(NULL, buffer, NULL, NULL, FALSE,
|
|
|
|
CREATE_SUSPENDED, NULL, NULL, &startup, &proc);
|
2008-09-04 13:08:53 +02:00
|
|
|
|
2009-10-08 11:25:20 +02:00
|
|
|
test_end_to_end_server(proc.hProcess, proc.hThread, FALSE);
|
2008-09-04 13:08:53 +02:00
|
|
|
|
2009-10-08 11:25:20 +02:00
|
|
|
sprintf(buffer, "%s dde endw", argv[0]);
|
|
|
|
CreateProcessA(NULL, buffer, NULL, NULL, FALSE,
|
|
|
|
CREATE_SUSPENDED, NULL, NULL, &startup, &proc);
|
2008-09-04 13:08:53 +02:00
|
|
|
|
2009-10-08 11:25:20 +02:00
|
|
|
test_end_to_end_server(proc.hProcess, proc.hThread, TRUE);
|
2008-09-04 13:08:53 +02:00
|
|
|
|
2010-06-23 14:19:51 +02:00
|
|
|
test_dde_aw_transaction( FALSE, TRUE );
|
|
|
|
test_dde_aw_transaction( TRUE, FALSE );
|
|
|
|
test_dde_aw_transaction( TRUE, TRUE );
|
|
|
|
test_dde_aw_transaction( FALSE, FALSE );
|
|
|
|
|
|
|
|
test_dde_aw_transaction( FALSE, TRUE );
|
|
|
|
test_dde_aw_transaction( TRUE, FALSE );
|
|
|
|
test_dde_aw_transaction( TRUE, TRUE );
|
|
|
|
}
|
|
|
|
test_dde_aw_transaction( FALSE, FALSE );
|
2007-10-04 07:28:45 +02:00
|
|
|
|
2007-10-12 07:22:54 +02:00
|
|
|
test_DdeCreateDataHandle();
|
2007-09-17 01:26:07 +02:00
|
|
|
test_DdeCreateStringHandle();
|
|
|
|
test_FreeDDElParam();
|
|
|
|
test_PackDDElParam();
|
|
|
|
test_UnpackDDElParam();
|
2005-07-08 13:33:09 +02:00
|
|
|
}
|