2 * Unit tests for DDE functions
4 * Copyright (c) 2004 Dmitry Timoshkov
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "wine/test.h"
29 static HDDEDATA CALLBACK
DdeCallback(UINT uType
, UINT uFmt
, HCONV hconv
,
30 HSZ hsz1
, HSZ hsz2
, HDDEDATA hdata
,
31 ULONG_PTR dwData1
, ULONG_PTR dwData2
)
36 static void test_DdeCreateStringHandleW(DWORD dde_inst
, int codepage
)
38 static const WCHAR dde_string
[] = {'D','D','E',' ','S','t','r','i','n','g',0};
44 str_handle
= DdeCreateStringHandleW(dde_inst
, dde_string
, codepage
);
45 ok(str_handle
!= 0, "DdeCreateStringHandleW failed with error %08x\n",
46 DdeGetLastError(dde_inst
));
48 ret
= DdeQueryStringW(dde_inst
, str_handle
, NULL
, 0, codepage
);
49 if (codepage
== CP_WINANSI
)
50 ok(ret
== 1, "DdeQueryStringW returned wrong length %d\n", ret
);
52 ok(ret
== lstrlenW(dde_string
), "DdeQueryStringW returned wrong length %d\n", ret
);
54 ret
= DdeQueryStringW(dde_inst
, str_handle
, bufW
, 256, codepage
);
55 if (codepage
== CP_WINANSI
)
57 ok(ret
== 1, "DdeQueryStringW returned wrong length %d\n", ret
);
58 ok(!lstrcmpA("D", (LPCSTR
)bufW
), "DdeQueryStringW returned wrong string\n");
62 ok(ret
== lstrlenW(dde_string
), "DdeQueryStringW returned wrong length %d\n", ret
);
63 ok(!lstrcmpW(dde_string
, bufW
), "DdeQueryStringW returned wrong string\n");
66 ret
= DdeQueryStringA(dde_inst
, str_handle
, buf
, 256, CP_WINANSI
);
67 if (codepage
== CP_WINANSI
)
69 ok(ret
== 1, "DdeQueryStringA returned wrong length %d\n", ret
);
70 ok(!lstrcmpA("D", buf
), "DdeQueryStringW returned wrong string\n");
74 ok(ret
== lstrlenA("DDE String"), "DdeQueryStringA returned wrong length %d\n", ret
);
75 ok(!lstrcmpA("DDE String", buf
), "DdeQueryStringA returned wrong string %s\n", buf
);
78 ret
= DdeQueryStringA(dde_inst
, str_handle
, buf
, 256, CP_WINUNICODE
);
79 if (codepage
== CP_WINANSI
)
81 ok(ret
== 1, "DdeQueryStringA returned wrong length %d\n", ret
);
82 ok(!lstrcmpA("D", buf
), "DdeQueryStringA returned wrong string %s\n", buf
);
86 ok(ret
== lstrlenA("DDE String"), "DdeQueryStringA returned wrong length %d\n", ret
);
87 ok(!lstrcmpW(dde_string
, (LPCWSTR
)buf
), "DdeQueryStringW returned wrong string\n");
90 ok(DdeFreeStringHandle(dde_inst
, str_handle
), "DdeFreeStringHandle failed\n");
97 dde_inst
= 0xdeadbeef;
98 SetLastError(0xdeadbeef);
99 ret
= DdeInitializeW(&dde_inst
, DdeCallback
, APPCMD_CLIENTONLY
, 0);
100 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
102 trace("Skipping the DDE test on a Win9x platform\n");
106 ok(ret
== DMLERR_INVALIDPARAMETER
, "DdeInitializeW should fail, but got %04lx instead\n", ret
);
107 ok(DdeGetLastError(dde_inst
) == DMLERR_INVALIDPARAMETER
, "expected DMLERR_INVALIDPARAMETER\n");
110 ret
= DdeInitializeW(&dde_inst
, DdeCallback
, APPCMD_CLIENTONLY
, 0);
111 ok(ret
== DMLERR_NO_ERROR
, "DdeInitializeW failed with error %04lx (%08x)\n",
112 ret
, DdeGetLastError(dde_inst
));
114 test_DdeCreateStringHandleW(dde_inst
, 0);
115 test_DdeCreateStringHandleW(dde_inst
, CP_WINUNICODE
);
116 test_DdeCreateStringHandleW(dde_inst
, CP_WINANSI
);
118 ok(DdeUninitialize(dde_inst
), "DdeUninitialize failed\n");