2 * ITypeLib and ITypeInfo test
4 * Copyright 2004 Jacek Caban
5 * Copyright 2006 Dmitry Timoshkov
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include <wine/test.h>
37 #define expect_eq(expr, value, type, format) { type _ret = (expr); ok((value) == _ret, #expr " expected " format " got " format "\n", value, _ret); }
38 #define expect_int(expr, value) expect_eq(expr, (int)(value), int, "%d")
39 #define expect_hex(expr, value) expect_eq(expr, (int)(value), int, "0x%x")
40 #define expect_null(expr) expect_eq(expr, NULL, const void *, "%p")
42 #define expect_wstr_acpval(expr, value) \
45 expect_eq(!WideCharToMultiByte(CP_ACP, 0, (expr), -1, buf, 260, NULL, NULL), 0, int, "%d"); \
46 ok(lstrcmp(value, buf) == 0, #expr " expected \"%s\" got \"%s\"\n", value, buf); \
49 #define ole_expect(expr, expect) { \
51 ok(r == (expect), #expr " returned %x, expected %s (%x)\n", r, #expect, expect); \
54 #define ole_check(expr) ole_expect(expr, S_OK);
56 #define ok_ole_success(hr, func) ok(hr == S_OK, #func " failed with error 0x%08x\n", hr)
58 static HRESULT
WINAPI (*pRegisterTypeLibForUser
)(ITypeLib
*,OLECHAR
*,OLECHAR
*);
59 static HRESULT
WINAPI (*pUnRegisterTypeLibForUser
)(REFGUID
,WORD
,WORD
,LCID
,SYSKIND
);
61 static const WCHAR wszStdOle2
[] = {'s','t','d','o','l','e','2','.','t','l','b',0};
62 static WCHAR wszGUID
[] = {'G','U','I','D',0};
63 static WCHAR wszguid
[] = {'g','u','i','d',0};
65 static const int is_win64
= sizeof(void *) > sizeof(int);
67 static void init_function_pointers(void)
69 HMODULE hmod
= GetModuleHandleA("oleaut32.dll");
71 pRegisterTypeLibForUser
= (void *)GetProcAddress(hmod
, "RegisterTypeLibForUser");
72 pUnRegisterTypeLibForUser
= (void *)GetProcAddress(hmod
, "UnRegisterTypeLibForUser");
75 static void ref_count_test(LPCWSTR type_lib
)
78 ITypeInfo
*iti1
, *iti2
;
82 trace("Loading type library\n");
83 hRes
= LoadTypeLib(type_lib
, &iface
);
84 ok(hRes
== S_OK
, "Could not load type library\n");
88 hRes
= ITypeLib_GetTypeInfo(iface
, 1, &iti1
);
89 ok(hRes
== S_OK
, "ITypeLib_GetTypeInfo failed on index = 1\n");
90 ok(ref_count
=ITypeLib_Release(iface
) > 0, "ITypeLib destroyed while ITypeInfo has back pointer\n");
94 hRes
= ITypeLib_GetTypeInfo(iface
, 1, &iti2
);
95 ok(hRes
== S_OK
, "ITypeLib_GetTypeInfo failed on index = 1\n");
96 ok(iti1
== iti2
, "ITypeLib_GetTypeInfo returned different pointers for same indexes\n");
98 ITypeLib_AddRef(iface
);
99 ITypeInfo_Release(iti2
);
100 ITypeInfo_Release(iti1
);
101 ok(ITypeLib_Release(iface
) == 0, "ITypeLib should be destroyed here.\n");
104 static void test_TypeComp(void)
107 ITypeComp
*pTypeComp
;
112 ITypeInfo
*pTypeInfo
;
113 ITypeInfo
*pFontTypeInfo
;
114 ITypeComp
*pTypeComp_tmp
;
115 static WCHAR wszStdFunctions
[] = {'S','t','d','F','u','n','c','t','i','o','n','s',0};
116 static WCHAR wszSavePicture
[] = {'S','a','v','e','P','i','c','t','u','r','e',0};
117 static WCHAR wszOLE_TRISTATE
[] = {'O','L','E','_','T','R','I','S','T','A','T','E',0};
118 static WCHAR wszUnchecked
[] = {'U','n','c','h','e','c','k','e','d',0};
119 static WCHAR wszIUnknown
[] = {'I','U','n','k','n','o','w','n',0};
120 static WCHAR wszFont
[] = {'F','o','n','t',0};
121 static WCHAR wszStdPicture
[] = {'S','t','d','P','i','c','t','u','r','e',0};
122 static WCHAR wszOLE_COLOR
[] = {'O','L','E','_','C','O','L','O','R',0};
123 static WCHAR wszClone
[] = {'C','l','o','n','e',0};
124 static WCHAR wszclone
[] = {'c','l','o','n','e',0};
125 static WCHAR wszJunk
[] = {'J','u','n','k',0};
126 static WCHAR wszAddRef
[] = {'A','d','d','R','e','f',0};
128 hr
= LoadTypeLib(wszStdOle2
, &pTypeLib
);
129 ok_ole_success(hr
, LoadTypeLib
);
131 hr
= ITypeLib_GetTypeComp(pTypeLib
, &pTypeComp
);
132 ok_ole_success(hr
, ITypeLib_GetTypeComp
);
134 /* test getting a TKIND_MODULE */
135 ulHash
= LHashValOfNameSys(SYS_WIN32
, LOCALE_NEUTRAL
, wszStdFunctions
);
136 hr
= ITypeComp_Bind(pTypeComp
, wszStdFunctions
, ulHash
, 0, &pTypeInfo
, &desckind
, &bindptr
);
137 ok_ole_success(hr
, ITypeComp_Bind
);
139 ok(desckind
== DESCKIND_TYPECOMP
,
140 "desckind should have been DESCKIND_TYPECOMP instead of %d\n",
142 ok(!pTypeInfo
, "pTypeInfo should have been set to NULL\n");
144 ITypeComp_Release(bindptr
.lptcomp
);
146 /* test getting a TKIND_MODULE with INVOKE_PROPERTYGET */
147 ulHash
= LHashValOfNameSys(SYS_WIN32
, LOCALE_NEUTRAL
, wszStdFunctions
);
148 hr
= ITypeComp_Bind(pTypeComp
, wszStdFunctions
, ulHash
, INVOKE_PROPERTYGET
, &pTypeInfo
, &desckind
, &bindptr
);
149 ok_ole_success(hr
, ITypeComp_Bind
);
151 ok(desckind
== DESCKIND_TYPECOMP
,
152 "desckind should have been DESCKIND_TYPECOMP instead of %d\n",
154 ok(!pTypeInfo
, "pTypeInfo should have been set to NULL\n");
155 ITypeComp_Release(bindptr
.lptcomp
);
157 /* test getting a function within a TKIND_MODULE */
158 ulHash
= LHashValOfNameSys(SYS_WIN32
, LOCALE_NEUTRAL
, wszSavePicture
);
159 hr
= ITypeComp_Bind(pTypeComp
, wszSavePicture
, ulHash
, 0, &pTypeInfo
, &desckind
, &bindptr
);
160 ok_ole_success(hr
, ITypeComp_Bind
);
162 ok(desckind
== DESCKIND_FUNCDESC
,
163 "desckind should have been DESCKIND_FUNCDESC instead of %d\n",
165 ok(bindptr
.lpfuncdesc
!= NULL
, "bindptr.lpfuncdesc should not have been set to NULL\n");
166 ITypeInfo_ReleaseFuncDesc(pTypeInfo
, bindptr
.lpfuncdesc
);
167 ITypeInfo_Release(pTypeInfo
);
169 /* test getting a function within a TKIND_MODULE with INVOKE_PROPERTYGET */
170 ulHash
= LHashValOfNameSys(SYS_WIN32
, LOCALE_NEUTRAL
, wszSavePicture
);
171 hr
= ITypeComp_Bind(pTypeComp
, wszSavePicture
, ulHash
, INVOKE_PROPERTYGET
, &pTypeInfo
, &desckind
, &bindptr
);
172 ok(hr
== TYPE_E_TYPEMISMATCH
,
173 "ITypeComp_Bind should have failed with TYPE_E_TYPEMISMATCH instead of 0x%08x\n",
176 ok(desckind
== DESCKIND_NONE
,
177 "desckind should have been DESCKIND_NONE instead of %d\n",
179 ok(!pTypeInfo
, "pTypeInfo should have been set to NULL\n");
180 ok(!bindptr
.lptcomp
, "bindptr should have been set to NULL\n");
182 /* test getting a TKIND_ENUM */
183 ulHash
= LHashValOfNameSys(SYS_WIN32
, LOCALE_NEUTRAL
, wszOLE_TRISTATE
);
184 hr
= ITypeComp_Bind(pTypeComp
, wszOLE_TRISTATE
, ulHash
, 0, &pTypeInfo
, &desckind
, &bindptr
);
185 ok_ole_success(hr
, ITypeComp_Bind
);
187 ok(desckind
== DESCKIND_TYPECOMP
,
188 "desckind should have been DESCKIND_TYPECOMP instead of %d\n",
190 ok(!pTypeInfo
, "pTypeInfo should have been set to NULL\n");
192 ITypeComp_Release(bindptr
.lptcomp
);
194 /* test getting a value within a TKIND_ENUM */
195 ulHash
= LHashValOfNameSys(SYS_WIN32
, LOCALE_NEUTRAL
, wszUnchecked
);
196 hr
= ITypeComp_Bind(pTypeComp
, wszUnchecked
, ulHash
, 0, &pTypeInfo
, &desckind
, &bindptr
);
197 ok_ole_success(hr
, ITypeComp_Bind
);
199 ok(desckind
== DESCKIND_VARDESC
,
200 "desckind should have been DESCKIND_VARDESC instead of %d\n",
202 ITypeInfo_ReleaseVarDesc(pTypeInfo
, bindptr
.lpvardesc
);
203 ITypeInfo_Release(pTypeInfo
);
205 /* test getting a TKIND_INTERFACE */
206 ulHash
= LHashValOfNameSys(SYS_WIN32
, LOCALE_NEUTRAL
, wszIUnknown
);
207 hr
= ITypeComp_Bind(pTypeComp
, wszIUnknown
, ulHash
, 0, &pTypeInfo
, &desckind
, &bindptr
);
208 ok_ole_success(hr
, ITypeComp_Bind
);
210 ok(desckind
== DESCKIND_NONE
,
211 "desckind should have been DESCKIND_NONE instead of %d\n",
213 ok(!pTypeInfo
, "pTypeInfo should have been set to NULL\n");
214 ok(!bindptr
.lptcomp
, "bindptr should have been set to NULL\n");
216 /* test getting a TKIND_DISPATCH */
217 ulHash
= LHashValOfNameSys(SYS_WIN32
, LOCALE_NEUTRAL
, wszFont
);
218 hr
= ITypeComp_Bind(pTypeComp
, wszFont
, ulHash
, 0, &pTypeInfo
, &desckind
, &bindptr
);
219 ok_ole_success(hr
, ITypeComp_Bind
);
221 ok(desckind
== DESCKIND_NONE
,
222 "desckind should have been DESCKIND_NONE instead of %d\n",
224 ok(!pTypeInfo
, "pTypeInfo should have been set to NULL\n");
225 ok(!bindptr
.lptcomp
, "bindptr should have been set to NULL\n");
227 /* test getting a TKIND_RECORD/TKIND_ALIAS */
228 ulHash
= LHashValOfNameSys(SYS_WIN32
, LOCALE_NEUTRAL
, wszGUID
);
229 hr
= ITypeComp_Bind(pTypeComp
, wszGUID
, ulHash
, 0, &pTypeInfo
, &desckind
, &bindptr
);
230 ok_ole_success(hr
, ITypeComp_Bind
);
232 ok(desckind
== DESCKIND_NONE
,
233 "desckind should have been DESCKIND_NONE instead of %d\n",
235 ok(!pTypeInfo
, "pTypeInfo should have been set to NULL\n");
236 ok(!bindptr
.lptcomp
, "bindptr should have been set to NULL\n");
238 /* test getting a TKIND_ALIAS */
239 ulHash
= LHashValOfNameSys(SYS_WIN32
, LOCALE_NEUTRAL
, wszOLE_COLOR
);
240 hr
= ITypeComp_Bind(pTypeComp
, wszOLE_COLOR
, ulHash
, 0, &pTypeInfo
, &desckind
, &bindptr
);
241 ok_ole_success(hr
, ITypeComp_Bind
);
243 ok(desckind
== DESCKIND_NONE
,
244 "desckind should have been DESCKIND_NONE instead of %d\n",
246 ok(!pTypeInfo
, "pTypeInfo should have been set to NULL\n");
247 ok(!bindptr
.lptcomp
, "bindptr should have been set to NULL\n");
249 /* test getting a TKIND_COCLASS */
250 ulHash
= LHashValOfNameSys(SYS_WIN32
, LOCALE_NEUTRAL
, wszStdPicture
);
251 hr
= ITypeComp_Bind(pTypeComp
, wszStdPicture
, ulHash
, 0, &pTypeInfo
, &desckind
, &bindptr
);
252 ok_ole_success(hr
, ITypeComp_Bind
);
254 ok(desckind
== DESCKIND_NONE
,
255 "desckind should have been DESCKIND_NONE instead of %d\n",
257 ok(!pTypeInfo
, "pTypeInfo should have been set to NULL\n");
258 ok(!bindptr
.lptcomp
, "bindptr should have been set to NULL\n");
260 /* test basic BindType argument handling */
261 ulHash
= LHashValOfNameSys(SYS_WIN32
, LOCALE_NEUTRAL
, wszGUID
);
262 hr
= ITypeComp_BindType(pTypeComp
, wszGUID
, ulHash
, NULL
, NULL
);
263 ok(hr
== E_INVALIDARG
, "Got %08x\n", hr
);
265 ulHash
= LHashValOfNameSys(SYS_WIN32
, LOCALE_NEUTRAL
, wszGUID
);
266 pTypeInfo
= (void*)0xdeadbeef;
267 hr
= ITypeComp_BindType(pTypeComp
, wszGUID
, ulHash
, &pTypeInfo
, NULL
);
268 ok(hr
== E_INVALIDARG
, "Got %08x\n", hr
);
269 ok(pTypeInfo
== (void*)0xdeadbeef, "Got %p\n", pTypeInfo
);
271 ulHash
= LHashValOfNameSys(SYS_WIN32
, LOCALE_NEUTRAL
, wszGUID
);
272 pTypeComp_tmp
= (void*)0xdeadbeef;
273 hr
= ITypeComp_BindType(pTypeComp
, wszGUID
, ulHash
, NULL
, &pTypeComp_tmp
);
274 ok(hr
== E_INVALIDARG
, "Got %08x\n", hr
);
275 ok(pTypeComp_tmp
== (void*)0xdeadbeef, "Got %p\n", pTypeComp_tmp
);
277 ulHash
= LHashValOfNameSys(SYS_WIN32
, LOCALE_NEUTRAL
, wszGUID
);
278 pTypeComp_tmp
= (void*)0xdeadbeef;
279 pTypeInfo
= (void*)0xdeadbeef;
280 hr
= ITypeComp_BindType(pTypeComp
, NULL
, ulHash
, &pTypeInfo
, &pTypeComp_tmp
);
281 ok(hr
== E_INVALIDARG
, "Got %08x\n", hr
);
282 ok(pTypeInfo
== (void*)0xdeadbeef, "Got %p\n", pTypeInfo
);
283 ok(pTypeComp_tmp
== (void*)0xdeadbeef, "Got %p\n", pTypeComp_tmp
);
285 ulHash
= LHashValOfNameSys(SYS_WIN32
, LOCALE_NEUTRAL
, wszGUID
);
286 pTypeComp_tmp
= (void*)0xdeadbeef;
287 pTypeInfo
= (void*)0xdeadbeef;
288 hr
= ITypeComp_BindType(pTypeComp
, wszGUID
, ulHash
, &pTypeInfo
, &pTypeComp_tmp
);
289 ok_ole_success(hr
, ITypeComp_BindType
);
290 ok(pTypeInfo
!= NULL
, "Got NULL pTypeInfo\n");
291 todo_wine
ok(pTypeComp_tmp
== NULL
, "Got pTypeComp_tmp %p\n", pTypeComp_tmp
);
292 ITypeInfo_Release(pTypeInfo
);
293 if(pTypeComp_tmp
) ITypeComp_Release(pTypeComp_tmp
); /* fixme */
295 /* test BindType case-insensitivity */
296 ulHash
= LHashValOfNameSys(SYS_WIN32
, LOCALE_NEUTRAL
, wszguid
);
297 pTypeComp_tmp
= (void*)0xdeadbeef;
298 pTypeInfo
= (void*)0xdeadbeef;
299 hr
= ITypeComp_BindType(pTypeComp
, wszguid
, ulHash
, &pTypeInfo
, &pTypeComp_tmp
);
300 ok_ole_success(hr
, ITypeComp_BindType
);
301 ok(pTypeInfo
!= NULL
, "Got NULL pTypeInfo\n");
302 todo_wine
ok(pTypeComp_tmp
== NULL
, "Got pTypeComp_tmp %p\n", pTypeComp_tmp
);
303 ITypeInfo_Release(pTypeInfo
);
304 if(pTypeComp_tmp
) ITypeComp_Release(pTypeComp_tmp
); /* fixme */
306 ITypeComp_Release(pTypeComp
);
308 /* tests for ITypeComp on an interface */
309 hr
= ITypeLib_GetTypeInfoOfGuid(pTypeLib
, &IID_IFont
, &pFontTypeInfo
);
310 ok_ole_success(hr
, ITypeLib_GetTypeInfoOfGuid
);
312 hr
= ITypeInfo_GetTypeComp(pFontTypeInfo
, &pTypeComp
);
313 ok_ole_success(hr
, ITypeLib_GetTypeComp
);
315 ulHash
= LHashValOfNameSys(SYS_WIN32
, LOCALE_NEUTRAL
, wszClone
);
316 hr
= ITypeComp_Bind(pTypeComp
, wszClone
, ulHash
, 0, &pTypeInfo
, &desckind
, &bindptr
);
317 ok_ole_success(hr
, ITypeComp_Bind
);
319 ok(desckind
== DESCKIND_FUNCDESC
,
320 "desckind should have been DESCKIND_FUNCDESC instead of %d\n",
322 ok(bindptr
.lpfuncdesc
!= NULL
, "bindptr.lpfuncdesc should not have been set to NULL\n");
323 ITypeInfo_ReleaseFuncDesc(pTypeInfo
, bindptr
.lpfuncdesc
);
324 ITypeInfo_Release(pTypeInfo
);
326 ulHash
= LHashValOfNameSys(SYS_WIN32
, LOCALE_NEUTRAL
, wszClone
);
327 hr
= ITypeComp_Bind(pTypeComp
, wszClone
, ulHash
, INVOKE_PROPERTYGET
, &pTypeInfo
, &desckind
, &bindptr
);
328 ok(hr
== TYPE_E_TYPEMISMATCH
, "ITypeComp_Bind should have failed with TYPE_E_TYPEMISMATCH instead of 0x%08x\n", hr
);
330 ok(desckind
== DESCKIND_NONE
,
331 "desckind should have been DESCKIND_NONE instead of %d\n",
333 ok(!pTypeInfo
, "pTypeInfo should have been set to NULL\n");
334 ok(!bindptr
.lptcomp
, "bindptr should have been set to NULL\n");
336 /* tests that the compare is case-insensitive */
337 ulHash
= LHashValOfNameSys(SYS_WIN32
, LOCALE_NEUTRAL
, wszclone
);
338 hr
= ITypeComp_Bind(pTypeComp
, wszclone
, ulHash
, 0, &pTypeInfo
, &desckind
, &bindptr
);
339 ok_ole_success(hr
, ITypeComp_Bind
);
341 ok(desckind
== DESCKIND_FUNCDESC
,
342 "desckind should have been DESCKIND_FUNCDESC instead of %d\n",
344 ok(bindptr
.lpfuncdesc
!= NULL
, "bindptr.lpfuncdesc should not have been set to NULL\n");
345 ITypeInfo_ReleaseFuncDesc(pTypeInfo
, bindptr
.lpfuncdesc
);
346 ITypeInfo_Release(pTypeInfo
);
348 /* tests nonexistent members */
349 desckind
= 0xdeadbeef;
350 bindptr
.lptcomp
= (ITypeComp
*)0xdeadbeef;
351 pTypeInfo
= (ITypeInfo
*)0xdeadbeef;
352 ulHash
= LHashValOfNameSys(SYS_WIN32
, LOCALE_NEUTRAL
, wszJunk
);
353 hr
= ITypeComp_Bind(pTypeComp
, wszJunk
, ulHash
, 0, &pTypeInfo
, &desckind
, &bindptr
);
354 ok_ole_success(hr
, ITypeComp_Bind
);
355 ok(desckind
== DESCKIND_NONE
, "desckind should have been DESCKIND_NONE, was: %d\n", desckind
);
356 ok(pTypeInfo
== NULL
, "pTypeInfo should have been NULL, was: %p\n", pTypeInfo
);
357 ok(bindptr
.lptcomp
== NULL
, "bindptr should have been NULL, was: %p\n", bindptr
.lptcomp
);
359 /* tests inherited members */
360 desckind
= 0xdeadbeef;
361 bindptr
.lpfuncdesc
= NULL
;
363 ulHash
= LHashValOfNameSys(SYS_WIN32
, LOCALE_NEUTRAL
, wszAddRef
);
364 hr
= ITypeComp_Bind(pTypeComp
, wszAddRef
, ulHash
, 0, &pTypeInfo
, &desckind
, &bindptr
);
365 ok_ole_success(hr
, ITypeComp_Bind
);
366 ok(desckind
== DESCKIND_FUNCDESC
, "desckind should have been DESCKIND_FUNCDESC, was: %d\n", desckind
);
367 ok(pTypeInfo
!= NULL
, "pTypeInfo should not have been NULL, was: %p\n", pTypeInfo
);
368 ok(bindptr
.lpfuncdesc
!= NULL
, "bindptr should not have been NULL, was: %p\n", bindptr
.lpfuncdesc
);
369 ITypeInfo_ReleaseFuncDesc(pTypeInfo
, bindptr
.lpfuncdesc
);
370 ITypeInfo_Release(pTypeInfo
);
372 ITypeComp_Release(pTypeComp
);
373 ITypeInfo_Release(pFontTypeInfo
);
374 ITypeLib_Release(pTypeLib
);
377 static void test_CreateDispTypeInfo(void)
379 ITypeInfo
*pTypeInfo
, *pTI2
;
381 INTERFACEDATA ifdata
;
382 METHODDATA methdata
[4];
390 static WCHAR func1
[] = {'f','u','n','c','1',0};
391 static const WCHAR func2
[] = {'f','u','n','c','2',0};
392 static const WCHAR func3
[] = {'f','u','n','c','3',0};
393 static const WCHAR parm1
[] = {'p','a','r','m','1',0};
394 static const WCHAR parm2
[] = {'p','a','r','m','2',0};
395 OLECHAR
*name
= func1
;
397 ifdata
.pmethdata
= methdata
;
398 ifdata
.cMembers
= sizeof(methdata
) / sizeof(methdata
[0]);
400 methdata
[0].szName
= SysAllocString(func1
);
401 methdata
[0].ppdata
= parms1
;
402 methdata
[0].dispid
= 0x123;
403 methdata
[0].iMeth
= 0;
404 methdata
[0].cc
= CC_STDCALL
;
405 methdata
[0].cArgs
= 2;
406 methdata
[0].wFlags
= DISPATCH_METHOD
;
407 methdata
[0].vtReturn
= VT_HRESULT
;
408 parms1
[0].szName
= SysAllocString(parm1
);
409 parms1
[0].vt
= VT_I4
;
410 parms1
[1].szName
= SysAllocString(parm2
);
411 parms1
[1].vt
= VT_BSTR
;
413 methdata
[1].szName
= SysAllocString(func2
);
414 methdata
[1].ppdata
= NULL
;
415 methdata
[1].dispid
= 0x124;
416 methdata
[1].iMeth
= 1;
417 methdata
[1].cc
= CC_STDCALL
;
418 methdata
[1].cArgs
= 0;
419 methdata
[1].wFlags
= DISPATCH_PROPERTYGET
;
420 methdata
[1].vtReturn
= VT_I4
;
422 methdata
[2].szName
= SysAllocString(func3
);
423 methdata
[2].ppdata
= parms3
;
424 methdata
[2].dispid
= 0x125;
425 methdata
[2].iMeth
= 3;
426 methdata
[2].cc
= CC_STDCALL
;
427 methdata
[2].cArgs
= 1;
428 methdata
[2].wFlags
= DISPATCH_PROPERTYPUT
;
429 methdata
[2].vtReturn
= VT_HRESULT
;
430 parms3
[0].szName
= SysAllocString(parm1
);
431 parms3
[0].vt
= VT_I4
;
433 methdata
[3].szName
= SysAllocString(func3
);
434 methdata
[3].ppdata
= NULL
;
435 methdata
[3].dispid
= 0x125;
436 methdata
[3].iMeth
= 4;
437 methdata
[3].cc
= CC_STDCALL
;
438 methdata
[3].cArgs
= 0;
439 methdata
[3].wFlags
= DISPATCH_PROPERTYGET
;
440 methdata
[3].vtReturn
= VT_I4
;
442 hr
= CreateDispTypeInfo(&ifdata
, LOCALE_NEUTRAL
, &pTypeInfo
);
443 ok(hr
== S_OK
, "hr %08x\n", hr
);
445 hr
= ITypeInfo_GetTypeAttr(pTypeInfo
, &pTypeAttr
);
446 ok(hr
== S_OK
, "hr %08x\n", hr
);
448 ok(pTypeAttr
->typekind
== TKIND_COCLASS
, "typekind %0x\n", pTypeAttr
->typekind
);
449 ok(pTypeAttr
->cImplTypes
== 1, "cImplTypes %d\n", pTypeAttr
->cImplTypes
);
450 ok(pTypeAttr
->cFuncs
== 0, "cFuncs %d\n", pTypeAttr
->cFuncs
);
451 ok(pTypeAttr
->wTypeFlags
== 0, "wTypeFlags %04x\n", pTypeAttr
->cFuncs
);
452 ITypeInfo_ReleaseTypeAttr(pTypeInfo
, pTypeAttr
);
454 hr
= ITypeInfo_GetRefTypeOfImplType(pTypeInfo
, 0, &href
);
455 ok(hr
== S_OK
, "hr %08x\n", hr
);
456 ok(href
== 0, "href = 0x%x\n", href
);
457 hr
= ITypeInfo_GetRefTypeInfo(pTypeInfo
, href
, &pTI2
);
458 ok(hr
== S_OK
, "hr %08x\n", hr
);
459 hr
= ITypeInfo_GetTypeAttr(pTI2
, &pTypeAttr
);
460 ok(hr
== S_OK
, "hr %08x\n", hr
);
461 ok(pTypeAttr
->typekind
== TKIND_INTERFACE
, "typekind %0x\n", pTypeAttr
->typekind
);
462 ok(pTypeAttr
->cFuncs
== 4, "cFuncs %d\n", pTypeAttr
->cFuncs
);
463 ok(IsEqualGUID(&pTypeAttr
->guid
, &GUID_NULL
), "guid {%08x-...}\n", pTypeAttr
->guid
.Data1
);
464 ok(pTypeAttr
->wTypeFlags
== 0, "typeflags %08x\n", pTypeAttr
->wTypeFlags
);
466 ITypeInfo_ReleaseTypeAttr(pTI2
, pTypeAttr
);
468 hr
= ITypeInfo_GetFuncDesc(pTI2
, 0, &pFuncDesc
);
469 ok(hr
== S_OK
, "hr %08x\n", hr
);
470 ok(pFuncDesc
->memid
== 0x123, "memid %x\n", pFuncDesc
->memid
);
471 ok(pFuncDesc
->funckind
== FUNC_VIRTUAL
, "funckind %d\n", pFuncDesc
->funckind
);
472 ok(pFuncDesc
->invkind
== methdata
[0].wFlags
, "invkind %d\n", pFuncDesc
->invkind
);
473 ok(pFuncDesc
->callconv
== methdata
[0].cc
, "callconv %d\n", pFuncDesc
->callconv
);
474 ok(pFuncDesc
->cParams
== methdata
[0].cArgs
, "cParams %d\n", pFuncDesc
->cParams
);
475 ok(pFuncDesc
->oVft
== 0, "oVft %d\n", pFuncDesc
->oVft
);
476 ok(pFuncDesc
->wFuncFlags
== 0, "oVft %d\n", pFuncDesc
->wFuncFlags
);
477 ok(pFuncDesc
->elemdescFunc
.tdesc
.vt
== VT_HRESULT
, "ret vt %x\n", pFuncDesc
->elemdescFunc
.tdesc
.vt
);
478 ok(pFuncDesc
->lprgelemdescParam
[0].tdesc
.vt
== VT_I4
, "parm 0 vt %x\n", pFuncDesc
->lprgelemdescParam
[0].tdesc
.vt
);
479 ok(U(pFuncDesc
->lprgelemdescParam
[0]).paramdesc
.wParamFlags
== PARAMFLAG_NONE
, "parm 0 flags %x\n", U(pFuncDesc
->lprgelemdescParam
[0]).paramdesc
.wParamFlags
);
481 ok(pFuncDesc
->lprgelemdescParam
[1].tdesc
.vt
== VT_BSTR
, "parm 1 vt %x\n", pFuncDesc
->lprgelemdescParam
[1].tdesc
.vt
);
482 ok(U(pFuncDesc
->lprgelemdescParam
[1]).paramdesc
.wParamFlags
== PARAMFLAG_NONE
, "parm 1 flags %x\n", U(pFuncDesc
->lprgelemdescParam
[1]).paramdesc
.wParamFlags
);
483 ITypeInfo_ReleaseFuncDesc(pTI2
, pFuncDesc
);
485 hr
= ITypeInfo_GetFuncDesc(pTI2
, 1, &pFuncDesc
);
486 ok(hr
== S_OK
, "hr %08x\n", hr
);
487 ok(pFuncDesc
->funckind
== FUNC_VIRTUAL
, "funckind %d\n", pFuncDesc
->funckind
);
488 ok(pFuncDesc
->invkind
== methdata
[1].wFlags
, "invkind %d\n", pFuncDesc
->invkind
);
489 ok(pFuncDesc
->callconv
== methdata
[1].cc
, "callconv %d\n", pFuncDesc
->callconv
);
490 ok(pFuncDesc
->cParams
== methdata
[1].cArgs
, "cParams %d\n", pFuncDesc
->cParams
);
491 ok(pFuncDesc
->oVft
== sizeof(void *), "oVft %d\n", pFuncDesc
->oVft
);
492 ok(pFuncDesc
->wFuncFlags
== 0, "oVft %d\n", pFuncDesc
->wFuncFlags
);
493 ok(pFuncDesc
->elemdescFunc
.tdesc
.vt
== VT_I4
, "ret vt %x\n", pFuncDesc
->elemdescFunc
.tdesc
.vt
);
494 ITypeInfo_ReleaseFuncDesc(pTI2
, pFuncDesc
);
496 hr
= ITypeInfo_GetFuncDesc(pTI2
, 2, &pFuncDesc
);
497 ok(hr
== S_OK
, "hr %08x\n", hr
);
498 ok(pFuncDesc
->funckind
== FUNC_VIRTUAL
, "funckind %d\n", pFuncDesc
->funckind
);
499 ok(pFuncDesc
->invkind
== methdata
[2].wFlags
, "invkind %d\n", pFuncDesc
->invkind
);
500 ok(pFuncDesc
->callconv
== methdata
[2].cc
, "callconv %d\n", pFuncDesc
->callconv
);
501 ok(pFuncDesc
->cParams
== methdata
[2].cArgs
, "cParams %d\n", pFuncDesc
->cParams
);
502 ok(pFuncDesc
->oVft
== 3 * sizeof(void *), "oVft %d\n", pFuncDesc
->oVft
);
503 ok(pFuncDesc
->wFuncFlags
== 0, "oVft %d\n", pFuncDesc
->wFuncFlags
);
504 ok(pFuncDesc
->elemdescFunc
.tdesc
.vt
== VT_HRESULT
, "ret vt %x\n", pFuncDesc
->elemdescFunc
.tdesc
.vt
);
505 ok(pFuncDesc
->lprgelemdescParam
[0].tdesc
.vt
== VT_I4
, "parm 0 vt %x\n", pFuncDesc
->lprgelemdescParam
[0].tdesc
.vt
);
506 ok(U(pFuncDesc
->lprgelemdescParam
[0]).paramdesc
.wParamFlags
== PARAMFLAG_NONE
, "parm 0 flags %x\n", U(pFuncDesc
->lprgelemdescParam
[0]).paramdesc
.wParamFlags
);
507 ITypeInfo_ReleaseFuncDesc(pTI2
, pFuncDesc
);
509 hr
= ITypeInfo_GetFuncDesc(pTI2
, 3, &pFuncDesc
);
510 ok(hr
== S_OK
, "hr %08x\n", hr
);
511 ok(pFuncDesc
->funckind
== FUNC_VIRTUAL
, "funckind %d\n", pFuncDesc
->funckind
);
512 ok(pFuncDesc
->invkind
== methdata
[3].wFlags
, "invkind %d\n", pFuncDesc
->invkind
);
513 ok(pFuncDesc
->callconv
== methdata
[3].cc
, "callconv %d\n", pFuncDesc
->callconv
);
514 ok(pFuncDesc
->cParams
== methdata
[3].cArgs
, "cParams %d\n", pFuncDesc
->cParams
);
515 ok(pFuncDesc
->oVft
== 4 * sizeof(void *), "oVft %d\n", pFuncDesc
->oVft
);
516 ok(pFuncDesc
->wFuncFlags
== 0, "oVft %d\n", pFuncDesc
->wFuncFlags
);
517 ok(pFuncDesc
->elemdescFunc
.tdesc
.vt
== VT_I4
, "ret vt %x\n", pFuncDesc
->elemdescFunc
.tdesc
.vt
);
518 ITypeInfo_ReleaseFuncDesc(pTI2
, pFuncDesc
);
520 /* test GetIDsOfNames on a coclass to see if it searches its interfaces */
521 hr
= ITypeInfo_GetIDsOfNames(pTypeInfo
, &name
, 1, &memid
);
522 ok(hr
== S_OK
, "hr 0x%08x\n", hr
);
523 ok(memid
== 0x123, "memid 0x%08x\n", memid
);
525 ITypeInfo_Release(pTI2
);
526 ITypeInfo_Release(pTypeInfo
);
528 SysFreeString(parms1
[0].szName
);
529 SysFreeString(parms1
[1].szName
);
530 SysFreeString(parms3
[0].szName
);
531 SysFreeString(methdata
[0].szName
);
532 SysFreeString(methdata
[1].szName
);
533 SysFreeString(methdata
[2].szName
);
534 SysFreeString(methdata
[3].szName
);
537 static void test_TypeInfo(void)
540 ITypeInfo
*pTypeInfo
;
541 ITypeInfo2
*pTypeInfo2
;
543 static WCHAR wszBogus
[] = { 'b','o','g','u','s',0 };
544 static WCHAR wszGetTypeInfo
[] = { 'G','e','t','T','y','p','e','I','n','f','o',0 };
545 static WCHAR wszClone
[] = {'C','l','o','n','e',0};
546 OLECHAR
* bogus
= wszBogus
;
547 OLECHAR
* pwszGetTypeInfo
= wszGetTypeInfo
;
548 OLECHAR
* pwszClone
= wszClone
;
550 DISPPARAMS dispparams
;
551 GUID bogusguid
= {0x806afb4f,0x13f7,0x42d2,{0x89,0x2c,0x6c,0x97,0xc3,0x6a,0x36,0xc1}};
556 hr
= LoadTypeLib(wszStdOle2
, &pTypeLib
);
557 ok_ole_success(hr
, LoadTypeLib
);
559 count
= ITypeLib_GetTypeInfoCount(pTypeLib
);
560 ok(count
> 0, "got %d\n", count
);
563 hr
= ITypeLib_GetTypeInfo(pTypeLib
, count
, &pTypeInfo
);
564 ok(hr
== TYPE_E_ELEMENTNOTFOUND
, "got 0x%08x\n", hr
);
566 hr
= ITypeLib_GetTypeInfo(pTypeLib
, 0, NULL
);
567 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
569 hr
= ITypeLib_GetLibAttr(pTypeLib
, NULL
);
570 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
572 hr
= ITypeLib_GetTypeInfoType(pTypeLib
, count
, &kind
);
573 ok(hr
== TYPE_E_ELEMENTNOTFOUND
, "got 0x%08x\n", hr
);
575 hr
= ITypeLib_GetTypeInfoType(pTypeLib
, count
, NULL
);
576 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
578 hr
= ITypeLib_GetTypeInfoType(pTypeLib
, 0, NULL
);
579 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
581 hr
= ITypeLib_GetTypeInfoOfGuid(pTypeLib
, &IID_IFont
, &pTypeInfo
);
582 ok_ole_success(hr
, ITypeLib_GetTypeInfoOfGuid
);
584 /* test nonexistent method name */
585 hr
= ITypeInfo_GetIDsOfNames(pTypeInfo
, &bogus
, 1, &dispidMember
);
586 ok(hr
== DISP_E_UNKNOWNNAME
,
587 "ITypeInfo_GetIDsOfNames should have returned DISP_E_UNKNOWNNAME instead of 0x%08x\n",
590 dispparams
.cArgs
= 0;
591 dispparams
.rgdispidNamedArgs
= NULL
;
592 dispparams
.rgvarg
= NULL
;
594 /* test dispparams not NULL */
596 /* invalid member id -- wrong flags -- cNamedArgs not bigger than cArgs */
597 dispparams
.cNamedArgs
= 0;
598 hr
= ITypeInfo_Invoke(pTypeInfo
, (void *)0xdeadbeef, 0xdeadbeef, DISPATCH_PROPERTYGET
, &dispparams
, NULL
, NULL
, NULL
);
599 ok(hr
== DISP_E_MEMBERNOTFOUND
, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr
);
600 /* invalid member id -- correct flags -- cNamedArgs not bigger than cArgs */
601 hr
= ITypeInfo_Invoke(pTypeInfo
, (void *)0xdeadbeef, 0xdeadbeef, DISPATCH_METHOD
, &dispparams
, NULL
, NULL
, NULL
);
602 ok(hr
== DISP_E_MEMBERNOTFOUND
, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr
);
604 /* invalid member id -- wrong flags -- cNamedArgs bigger than cArgs */
605 dispparams
.cNamedArgs
= 1;
606 hr
= ITypeInfo_Invoke(pTypeInfo
, (void *)0xdeadbeef, 0xdeadbeef, DISPATCH_PROPERTYGET
, &dispparams
, NULL
, NULL
, NULL
);
607 ok(hr
== E_INVALIDARG
, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr
);
608 /* invalid member id -- correct flags -- cNamedArgs bigger than cArgs */
609 hr
= ITypeInfo_Invoke(pTypeInfo
, (void *)0xdeadbeef, 0xdeadbeef, DISPATCH_METHOD
, &dispparams
, NULL
, NULL
, NULL
);
610 ok(hr
== E_INVALIDARG
, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr
);
613 hr
= ITypeInfo_GetIDsOfNames(pTypeInfo
, &pwszClone
, 1, &dispidMember
);
614 ok_ole_success(hr
, ITypeInfo_GetIDsOfNames
);
616 /* correct member id -- wrong flags -- cNamedArgs not bigger than cArgs */
617 dispparams
.cNamedArgs
= 0;
618 hr
= ITypeInfo_Invoke(pTypeInfo
, (void *)0xdeadbeef, dispidMember
, DISPATCH_PROPERTYGET
, &dispparams
, NULL
, NULL
, NULL
);
619 ok(hr
== DISP_E_MEMBERNOTFOUND
, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr
);
620 /* correct member id -- correct flags -- cNamedArgs not bigger than cArgs */
621 hr
= ITypeInfo_Invoke(pTypeInfo
, (void *)0xdeadbeef, dispidMember
, DISPATCH_METHOD
, &dispparams
, NULL
, NULL
, NULL
);
622 ok(hr
== DISP_E_BADPARAMCOUNT
, "ITypeInfo_Invoke should have returned DISP_E_BADPARAMCOUNT instead of 0x%08x\n", hr
);
624 /* correct member id -- wrong flags -- cNamedArgs bigger than cArgs */
625 dispparams
.cNamedArgs
= 1;
626 hr
= ITypeInfo_Invoke(pTypeInfo
, (void *)0xdeadbeef, dispidMember
, DISPATCH_PROPERTYGET
, &dispparams
, NULL
, NULL
, NULL
);
627 ok(hr
== E_INVALIDARG
, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr
);
628 /* correct member id -- correct flags -- cNamedArgs bigger than cArgs */
629 hr
= ITypeInfo_Invoke(pTypeInfo
, (void *)0xdeadbeef, dispidMember
, DISPATCH_METHOD
, &dispparams
, NULL
, NULL
, NULL
);
630 ok(hr
== E_INVALIDARG
, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr
);
632 /* test NULL dispparams */
634 /* correct member id -- wrong flags -- cNamedArgs not bigger than cArgs */
635 dispparams
.cNamedArgs
= 0;
636 hr
= ITypeInfo_Invoke(pTypeInfo
, (void *)0xdeadbeef, dispidMember
, DISPATCH_PROPERTYGET
, NULL
, NULL
, NULL
, NULL
);
637 ok(hr
== E_INVALIDARG
, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr
);
638 /* correct member id -- correct flags -- cNamedArgs not bigger than cArgs */
639 hr
= ITypeInfo_Invoke(pTypeInfo
, (void *)0xdeadbeef, dispidMember
, DISPATCH_METHOD
, NULL
, NULL
, NULL
, NULL
);
640 ok(hr
== E_INVALIDARG
, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr
);
642 /* correct member id -- wrong flags -- cNamedArgs bigger than cArgs */
643 dispparams
.cNamedArgs
= 1;
644 hr
= ITypeInfo_Invoke(pTypeInfo
, (void *)0xdeadbeef, dispidMember
, DISPATCH_PROPERTYGET
, NULL
, NULL
, NULL
, NULL
);
645 ok(hr
== E_INVALIDARG
, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr
);
646 /* correct member id -- correct flags -- cNamedArgs bigger than cArgs */
647 hr
= ITypeInfo_Invoke(pTypeInfo
, (void *)0xdeadbeef, dispidMember
, DISPATCH_METHOD
, NULL
, NULL
, NULL
, NULL
);
648 ok(hr
== E_INVALIDARG
, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr
);
650 ITypeInfo_Release(pTypeInfo
);
654 hr
= ITypeLib_GetTypeInfoOfGuid(pTypeLib
, &IID_IDispatch
, &pTypeInfo
);
655 ok_ole_success(hr
, ITypeLib_GetTypeInfoOfGuid
);
657 hr
= ITypeInfo_GetIDsOfNames(pTypeInfo
, &pwszGetTypeInfo
, 1, &dispidMember
);
658 ok_ole_success(hr
, ITypeInfo_GetIDsOfNames
);
660 hr
= ITypeInfo_QueryInterface(pTypeInfo
, &IID_ITypeInfo2
, (void**)&pTypeInfo2
);
661 ok_ole_success(hr
, ITypeInfo_QueryInterface
);
669 /* test unknown guid passed to GetCustData */
670 hr
= ITypeInfo2_GetCustData(pTypeInfo2
, &bogusguid
, &var
);
671 ok_ole_success(hr
, ITypeInfo_GetCustData
);
672 ok(V_VT(&var
) == VT_EMPTY
, "got %i, expected VT_EMPTY\n", V_VT(&var
));
674 ITypeInfo2_Release(pTypeInfo2
);
679 /* test invoking a method with a [restricted] keyword */
681 /* correct member id -- wrong flags -- cNamedArgs not bigger than cArgs */
682 dispparams
.cNamedArgs
= 0;
683 hr
= ITypeInfo_Invoke(pTypeInfo
, (void *)0xdeadbeef, dispidMember
, DISPATCH_PROPERTYGET
, &dispparams
, NULL
, NULL
, NULL
);
684 ok(hr
== DISP_E_MEMBERNOTFOUND
, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr
);
685 /* correct member id -- correct flags -- cNamedArgs not bigger than cArgs */
686 hr
= ITypeInfo_Invoke(pTypeInfo
, (void *)0xdeadbeef, dispidMember
, DISPATCH_METHOD
, &dispparams
, NULL
, NULL
, NULL
);
687 ok(hr
== DISP_E_MEMBERNOTFOUND
, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr
);
689 /* correct member id -- wrong flags -- cNamedArgs bigger than cArgs */
690 dispparams
.cNamedArgs
= 1;
691 hr
= ITypeInfo_Invoke(pTypeInfo
, (void *)0xdeadbeef, dispidMember
, DISPATCH_PROPERTYGET
, &dispparams
, NULL
, NULL
, NULL
);
692 ok(hr
== DISP_E_MEMBERNOTFOUND
, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr
);
693 /* correct member id -- correct flags -- cNamedArgs bigger than cArgs */
694 hr
= ITypeInfo_Invoke(pTypeInfo
, (void *)0xdeadbeef, dispidMember
, DISPATCH_METHOD
, &dispparams
, NULL
, NULL
, NULL
);
695 ok(hr
== DISP_E_MEMBERNOTFOUND
, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr
);
697 /* test NULL dispparams */
699 /* correct member id -- wrong flags -- cNamedArgs not bigger than cArgs */
700 dispparams
.cNamedArgs
= 0;
701 hr
= ITypeInfo_Invoke(pTypeInfo
, (void *)0xdeadbeef, dispidMember
, DISPATCH_PROPERTYGET
, NULL
, NULL
, NULL
, NULL
);
702 ok(hr
== DISP_E_MEMBERNOTFOUND
, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr
);
703 /* correct member id -- correct flags -- cNamedArgs not bigger than cArgs */
704 hr
= ITypeInfo_Invoke(pTypeInfo
, (void *)0xdeadbeef, dispidMember
, DISPATCH_METHOD
, NULL
, NULL
, NULL
, NULL
);
705 ok(hr
== DISP_E_MEMBERNOTFOUND
, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr
);
707 /* correct member id -- wrong flags -- cNamedArgs bigger than cArgs */
708 dispparams
.cNamedArgs
= 1;
709 hr
= ITypeInfo_Invoke(pTypeInfo
, (void *)0xdeadbeef, dispidMember
, DISPATCH_PROPERTYGET
, NULL
, NULL
, NULL
, NULL
);
710 ok(hr
== DISP_E_MEMBERNOTFOUND
, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr
);
711 /* correct member id -- correct flags -- cNamedArgs bigger than cArgs */
712 hr
= ITypeInfo_Invoke(pTypeInfo
, (void *)0xdeadbeef, dispidMember
, DISPATCH_METHOD
, NULL
, NULL
, NULL
, NULL
);
713 ok(hr
== DISP_E_MEMBERNOTFOUND
, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr
);
715 ITypeInfo_Release(pTypeInfo
);
716 ITypeLib_Release(pTypeLib
);
719 static int WINAPI
int_func( int a0
, int a1
, int a2
, int a3
, int a4
)
721 ok( a0
== 1, "wrong arg0 %x\n", a0
);
722 ok( a1
== -1, "wrong arg1 %x\n", a1
);
723 ok( a2
== (0x55550000 | 1234), "wrong arg2 %x\n", a2
);
724 ok( a3
== 0xdeadbeef, "wrong arg3 %x\n", a3
);
725 ok( a4
== 0x555555fd, "wrong arg4 %x\n", a4
);
729 static double WINAPI
double_func( double a0
, float a1
, double a2
, int a3
)
731 ok( a0
== 1.2, "wrong arg0 %f\n", (double)a0
);
732 ok( a1
== 3.25, "wrong arg1 %f\n", (double)a1
);
733 ok( a2
== 1.2e12
, "wrong arg2 %f\n", (double)a2
);
734 ok( a3
== -4433.0, "wrong arg3 %f\n", (double)a3
);
738 static LONGLONG WINAPI
longlong_func( LONGLONG a0
, CY a1
)
740 ok( a0
== (((ULONGLONG
)0xdead << 32) | 0xbeef), "wrong arg0 %08x%08x\n", (DWORD
)(a0
>> 32), (DWORD
)a0
);
741 ok( a1
.int64
== ((ULONGLONG
)10000 * 12345678), "wrong arg1 %08x%08x\n",
742 (DWORD
)(a1
.int64
>> 32), (DWORD
)a1
.int64
);
743 return ((ULONGLONG
)4321 << 32) | 8765;
746 static VARIANT WINAPI
variant_func( int a0
, BOOL a1
, DECIMAL a2
, VARIANT a3
)
749 ok( a0
== 2233, "wrong arg0 %x\n", a0
);
750 ok( a1
== 1 || broken(a1
== 0x55550001), "wrong arg1 %x\n", a1
);
751 V_VT(&var
) = VT_LPWSTR
;
752 V_UI4(&var
) = 0xbabe;
753 ok( a2
.Hi32
== 1122, "wrong arg2.Hi32 %x\n", a2
.Hi32
);
754 ok( U1(a2
).Lo64
== 3344, "wrong arg2.Lo64 %08x%08x\n", (DWORD
)(U1(a2
).Lo64
>> 32), (DWORD
)U1(a2
).Lo64
);
755 ok( V_VT(&a3
) == VT_EMPTY
, "wrong arg3 type %x\n", V_VT(&a3
) );
756 ok( V_UI4(&a3
) == 0xdeadbeef, "wrong arg3 value %x\n", V_UI4(&a3
) );
760 static int CDECL
void_func( int a0
, int a1
)
762 if (is_win64
) /* VT_EMPTY is passed as real arg on win64 */
764 ok( a0
== 0x55555555, "wrong arg0 %x\n", a0
);
765 ok( a1
== 1111, "wrong arg1 %x\n", a1
);
769 ok( a0
== 1111, "wrong arg0 %x\n", a0
);
770 ok( a1
== 0, "wrong arg1 %x\n", a1
);
775 static int WINAPI
stdcall_func( int a
)
780 static int WINAPI
inst_func( void *inst
, int a
)
782 ok( (*(void ***)inst
)[3] == inst_func
, "wrong ptr %p\n", inst
);
783 ok( a
== 3, "wrong arg %x\n", a
);
787 static const void *vtable
[] = { NULL
, NULL
, NULL
, inst_func
};
789 static void test_DispCallFunc(void)
791 const void **inst
= vtable
;
793 VARIANT result
, args
[5];
794 VARIANTARG
*pargs
[5];
798 for (i
= 0; i
< 5; i
++) pargs
[i
] = &args
[i
];
800 memset( args
, 0x55, sizeof(args
) );
806 V_I2(&args
[2]) = 1234;
808 V_UI4(&args
[3]) = 0xdeadbeef;
811 memset( &result
, 0xcc, sizeof(result
) );
812 res
= DispCallFunc( NULL
, (ULONG_PTR
)int_func
, CC_STDCALL
, VT_UI4
, 5, types
, pargs
, &result
);
813 ok( res
== S_OK
, "DispCallFunc failed %x\n", res
);
814 ok( V_VT(&result
) == VT_UI4
, "wrong result type %d\n", V_VT(&result
) );
815 ok( V_UI4(&result
) == 4321, "wrong result %u\n", V_UI4(&result
) );
817 /* the function checks the argument sizes for stdcall */
818 if (!is_win64
) /* no stdcall on 64-bit */
820 res
= DispCallFunc( NULL
, (ULONG_PTR
)stdcall_func
, CC_STDCALL
, VT_UI4
, 0, types
, pargs
, &result
);
821 ok( res
== DISP_E_BADCALLEE
, "DispCallFunc wrong error %x\n", res
);
822 res
= DispCallFunc( NULL
, (ULONG_PTR
)stdcall_func
, CC_STDCALL
, VT_UI4
, 1, types
, pargs
, &result
);
823 ok( res
== S_OK
, "DispCallFunc failed %x\n", res
);
824 res
= DispCallFunc( NULL
, (ULONG_PTR
)stdcall_func
, CC_STDCALL
, VT_UI4
, 2, types
, pargs
, &result
);
825 ok( res
== DISP_E_BADCALLEE
, "DispCallFunc wrong error %x\n", res
);
828 memset( args
, 0x55, sizeof(args
) );
830 V_R8(&args
[0]) = 1.2;
832 V_R4(&args
[1]) = 3.25;
834 V_R8(&args
[2]) = 1.2e12
;
836 V_I4(&args
[3]) = -4433;
837 memset( &result
, 0xcc, sizeof(result
) );
838 res
= DispCallFunc( NULL
, (ULONG_PTR
)double_func
, CC_STDCALL
, VT_R8
, 4, types
, pargs
, &result
);
839 ok( res
== S_OK
, "DispCallFunc failed %x\n", res
);
840 ok( V_VT(&result
) == VT_R8
, "wrong result type %d\n", V_VT(&result
) );
841 ok( V_R8(&result
) == 4321, "wrong result %f\n", V_R8(&result
) );
843 memset( args
, 0x55, sizeof(args
) );
845 V_I8(&args
[0]) = ((ULONGLONG
)0xdead << 32) | 0xbeef;
847 V_CY(&args
[1]).int64
= (ULONGLONG
)10000 * 12345678;
848 memset( &result
, 0xcc, sizeof(result
) );
849 res
= DispCallFunc( NULL
, (ULONG_PTR
)longlong_func
, CC_STDCALL
, VT_I8
, 2, types
, pargs
, &result
);
850 ok( res
== S_OK
|| broken(res
== E_INVALIDARG
), /* longlong not supported on <= win2k */
851 "DispCallFunc failed %x\n", res
);
854 ok( V_VT(&result
) == VT_I8
, "wrong result type %d\n", V_VT(&result
) );
855 ok( V_I8(&result
) == (((ULONGLONG
)4321 << 32) | 8765), "wrong result %08x%08x\n",
856 (DWORD
)(V_I8(&result
) >> 32), (DWORD
)V_I8(&result
) );
859 memset( args
, 0x55, sizeof(args
) );
861 V_I4(&args
[0]) = 2233;
863 V_BOOL(&args
[1]) = 1;
864 types
[2] = VT_DECIMAL
;
865 V_DECIMAL(&args
[2]).Hi32
= 1122;
866 U1(V_DECIMAL(&args
[2])).Lo64
= 3344;
867 types
[3] = VT_VARIANT
;
868 V_VT(&args
[3]) = VT_EMPTY
;
869 V_UI4(&args
[3]) = 0xdeadbeef;
871 memset( &result
, 0xcc, sizeof(result
) );
872 res
= DispCallFunc( NULL
, (ULONG_PTR
)variant_func
, CC_STDCALL
, VT_VARIANT
, 5, types
, pargs
, &result
);
873 ok( res
== S_OK
, "DispCallFunc failed %x\n", res
);
874 ok( V_VT(&result
) == VT_LPWSTR
, "wrong result type %d\n", V_VT(&result
) );
875 ok( V_UI4(&result
) == 0xbabe, "wrong result %08x\n", V_UI4(&result
) );
877 memset( args
, 0x55, sizeof(args
) );
880 V_I4(&args
[1]) = 1111;
885 memset( &result
, 0xcc, sizeof(result
) );
886 res
= DispCallFunc( NULL
, (ULONG_PTR
)void_func
, CC_CDECL
, VT_EMPTY
, 5, types
, pargs
, &result
);
887 ok( res
== S_OK
, "DispCallFunc failed %x\n", res
);
888 ok( V_VT(&result
) == VT_EMPTY
, "wrong result type %d\n", V_VT(&result
) );
890 ok( V_UI4(&result
) == 12, "wrong result %08x\n", V_UI4(&result
) );
892 ok( V_UI4(&result
) == 0xcccccccc, "wrong result %08x\n", V_UI4(&result
) );
894 memset( args
, 0x55, sizeof(args
) );
897 memset( &result
, 0xcc, sizeof(result
) );
898 res
= DispCallFunc( &inst
, 3 * sizeof(void*), CC_STDCALL
, VT_I4
, 1, types
, pargs
, &result
);
899 ok( res
== S_OK
, "DispCallFunc failed %x\n", res
);
900 ok( V_VT(&result
) == VT_I4
, "wrong result type %d\n", V_VT(&result
) );
901 ok( V_I4(&result
) == 6, "wrong result %08x\n", V_I4(&result
) );
904 /* RegDeleteTreeW from dlls/advapi32/registry.c */
905 static LSTATUS
myRegDeleteTreeW(HKEY hKey
, LPCWSTR lpszSubKey
)
908 DWORD dwMaxSubkeyLen
, dwMaxValueLen
;
909 DWORD dwMaxLen
, dwSize
;
910 WCHAR szNameBuf
[MAX_PATH
], *lpszName
= szNameBuf
;
915 ret
= RegOpenKeyExW(hKey
, lpszSubKey
, 0, KEY_READ
, &hSubKey
);
919 ret
= RegQueryInfoKeyW(hSubKey
, NULL
, NULL
, NULL
, NULL
,
920 &dwMaxSubkeyLen
, NULL
, NULL
, &dwMaxValueLen
, NULL
, NULL
, NULL
);
921 if (ret
) goto cleanup
;
925 dwMaxLen
= max(dwMaxSubkeyLen
, dwMaxValueLen
);
926 if (dwMaxLen
> sizeof(szNameBuf
)/sizeof(WCHAR
))
928 /* Name too big: alloc a buffer for it */
929 if (!(lpszName
= HeapAlloc( GetProcessHeap(), 0, dwMaxLen
*sizeof(WCHAR
))))
931 ret
= ERROR_NOT_ENOUGH_MEMORY
;
936 /* Recursively delete all the subkeys */
940 if (RegEnumKeyExW(hSubKey
, 0, lpszName
, &dwSize
, NULL
,
941 NULL
, NULL
, NULL
)) break;
943 ret
= myRegDeleteTreeW(hSubKey
, lpszName
);
944 if (ret
) goto cleanup
;
948 ret
= RegDeleteKeyW(hKey
, lpszSubKey
);
953 if (RegEnumValueW(hKey
, 0, lpszName
, &dwSize
,
954 NULL
, NULL
, NULL
, NULL
)) break;
956 ret
= RegDeleteValueW(hKey
, lpszName
);
957 if (ret
) goto cleanup
;
961 if (lpszName
!= szNameBuf
)
962 HeapFree(GetProcessHeap(), 0, lpszName
);
964 RegCloseKey(hSubKey
);
968 static BOOL
do_typelib_reg_key(GUID
*uid
, WORD maj
, WORD min
, DWORD arch
, LPCWSTR base
, BOOL remove
)
970 static const WCHAR typelibW
[] = {'T','y','p','e','l','i','b','\\',0};
971 static const WCHAR formatW
[] = {'\\','%','u','.','%','u','\\','0','\\','w','i','n','%','u',0};
972 static const WCHAR format2W
[] = {'%','s','_','%','u','_','%','u','.','d','l','l',0};
978 memcpy(buf
, typelibW
, sizeof(typelibW
));
979 StringFromGUID2(uid
, buf
+ lstrlenW(buf
), 40);
983 ok(myRegDeleteTreeW(HKEY_CLASSES_ROOT
, buf
) == ERROR_SUCCESS
, "SHDeleteKey failed\n");
987 wsprintfW(buf
+ lstrlenW(buf
), formatW
, maj
, min
, arch
);
989 SetLastError(0xdeadbeef);
990 res
= RegCreateKeyExW(HKEY_CLASSES_ROOT
, buf
, 0, NULL
, 0,
991 KEY_WRITE
, NULL
, &hkey
, NULL
);
992 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
994 win_skip("W-calls are not implemented\n");
998 if (res
!= ERROR_SUCCESS
)
1000 trace("RegCreateKeyExW failed: %u\n", res
);
1004 wsprintfW(buf
, format2W
, base
, maj
, min
);
1005 if (RegSetValueExW(hkey
, NULL
, 0, REG_SZ
,
1006 (BYTE
*)buf
, (lstrlenW(buf
) + 1) * sizeof(WCHAR
)) != ERROR_SUCCESS
)
1008 trace("RegSetValueExW failed\n");
1015 static void test_QueryPathOfRegTypeLib(DWORD arch
)
1017 static const struct test_data
1021 const WCHAR path
[16];
1023 { 1, 0, TYPE_E_LIBNOTREGISTERED
, { 0 } },
1024 { 3, 0, S_OK
, {'f','a','k','e','_','3','_','0','.','d','l','l',0 } },
1025 { 3, 1, S_OK
, {'f','a','k','e','_','3','_','1','.','d','l','l',0 } },
1026 { 3, 22, S_OK
, {'f','a','k','e','_','3','_','3','7','.','d','l','l',0 } },
1027 { 3, 37, S_OK
, {'f','a','k','e','_','3','_','3','7','.','d','l','l',0 } },
1028 { 3, 40, S_OK
, {'f','a','k','e','_','3','_','3','7','.','d','l','l',0 } },
1029 { 0xffff, 0xffff, S_OK
, {'f','a','k','e','_','5','_','3','7','.','d','l','l',0 } },
1030 { 0xffff, 0, TYPE_E_LIBNOTREGISTERED
, { 0 } },
1031 { 3, 0xffff, TYPE_E_LIBNOTREGISTERED
, { 0 } },
1032 { 5, 0xffff, TYPE_E_LIBNOTREGISTERED
, { 0 } },
1033 { 4, 0, TYPE_E_LIBNOTREGISTERED
, { 0 } }
1035 static const WCHAR base
[] = {'f','a','k','e',0};
1036 static const WCHAR wrongW
[] = {'w','r','o','n','g',0};
1044 status
= UuidCreate(&uid
);
1045 ok(!status
|| status
== RPC_S_UUID_LOCAL_ONLY
, "UuidCreate error %08x\n", status
);
1047 StringFromGUID2(&uid
, uid_str
, 40);
1048 /*trace("GUID: %s\n", wine_dbgstr_w(uid_str));*/
1050 if (!do_typelib_reg_key(&uid
, 3, 0, arch
, base
, 0)) return;
1051 if (!do_typelib_reg_key(&uid
, 3, 1, arch
, base
, 0)) return;
1052 if (!do_typelib_reg_key(&uid
, 3, 37, arch
, base
, 0)) return;
1053 if (!do_typelib_reg_key(&uid
, 5, 37, arch
, base
, 0)) return;
1054 if (arch
== 64 && !do_typelib_reg_key(&uid
, 5, 37, 32, wrongW
, 0)) return;
1056 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
1058 ret
= QueryPathOfRegTypeLib(&uid
, td
[i
].maj
, td
[i
].min
, 0, &path
);
1059 ok(ret
== td
[i
].ret
, "QueryPathOfRegTypeLib(%u.%u) returned %08x\n", td
[i
].maj
, td
[i
].min
, ret
);
1062 ok(!lstrcmpW(td
[i
].path
, path
), "typelib %u.%u path doesn't match\n", td
[i
].maj
, td
[i
].min
);
1063 SysFreeString(path
);
1067 do_typelib_reg_key(&uid
, 0, 0, arch
, NULL
, 1);
1070 static void test_inheritance(void)
1074 ITypeInfo
*pTI
, *pTI_p
;
1078 WCHAR path
[MAX_PATH
];
1079 CHAR pathA
[MAX_PATH
];
1080 static const WCHAR tl_path
[] = {'.','\\','m','i','d','l','_','t','m','a','r','s','h','a','l','.','t','l','b',0};
1082 BOOL use_midl_tlb
= 0;
1084 GetModuleFileNameA(NULL
, pathA
, MAX_PATH
);
1085 MultiByteToWideChar(CP_ACP
, 0, pathA
, -1, path
, MAX_PATH
);
1088 memcpy(path
, tl_path
, sizeof(tl_path
));
1090 hr
= LoadTypeLib(path
, &pTL
);
1091 if(FAILED(hr
)) return;
1094 /* ItestIF3 is a syntax 2 dispinterface */
1095 hr
= ITypeLib_GetTypeInfoOfGuid(pTL
, &DIID_ItestIF3
, &pTI
);
1096 ok(hr
== S_OK
, "hr %08x\n", hr
);
1098 hr
= ITypeInfo_GetTypeAttr(pTI
, &pTA
);
1099 ok(hr
== S_OK
, "hr %08x\n", hr
);
1100 ok(pTA
->typekind
== TKIND_DISPATCH
, "kind %04x\n", pTA
->typekind
);
1101 ok(pTA
->cbSizeVft
== 7 * sizeof(void *), "sizevft %d\n", pTA
->cbSizeVft
);
1102 ok(pTA
->wTypeFlags
== TYPEFLAG_FDISPATCHABLE
, "typeflags %x\n", pTA
->wTypeFlags
);
1104 ok(pTA
->cFuncs
== 6, "cfuncs %d\n", pTA
->cFuncs
);
1105 ok(pTA
->cImplTypes
== 1, "cimpltypes %d\n", pTA
->cImplTypes
);
1107 ITypeInfo_ReleaseTypeAttr(pTI
, pTA
);
1110 hr
= ITypeInfo_GetRefTypeOfImplType(pTI
, 0, &href
);
1111 ok(hr
== S_OK
, "hr %08x\n", hr
);
1112 hr
= ITypeInfo_GetRefTypeInfo(pTI
, href
, &pTI_p
);
1113 ok(hr
== S_OK
, "hr %08x\n", hr
);
1114 hr
= ITypeInfo_GetTypeAttr(pTI_p
, &pTA
);
1115 ok(hr
== S_OK
, "got %08x\n", hr
);
1116 ok(IsEqualGUID(&pTA
->guid
, &IID_IDispatch
), "guid {%08x-....\n", pTA
->guid
.Data1
);
1117 ITypeInfo_ReleaseTypeAttr(pTI_p
, pTA
);
1118 ITypeInfo_Release(pTI_p
);
1120 /* Should have six methods */
1121 hr
= ITypeInfo_GetFuncDesc(pTI
, 6, &pFD
);
1122 ok(hr
== TYPE_E_ELEMENTNOTFOUND
, "hr %08x\n", hr
);
1123 hr
= ITypeInfo_GetFuncDesc(pTI
, 5, &pFD
);
1124 ok(hr
== S_OK
, "hr %08x\n", hr
);
1125 ok(pFD
->memid
== 0x60020000, "memid %08x\n", pFD
->memid
);
1126 ok(pFD
->oVft
== 5 * sizeof(void *), "oVft %d\n", pFD
->oVft
);
1127 ITypeInfo_ReleaseFuncDesc(pTI
, pFD
);
1129 ITypeInfo_Release(pTI
);
1132 /* ItestIF4 is a syntax 1 dispinterface */
1133 hr
= ITypeLib_GetTypeInfoOfGuid(pTL
, &DIID_ItestIF4
, &pTI
);
1134 ok(hr
== S_OK
, "hr %08x\n", hr
);
1136 hr
= ITypeInfo_GetTypeAttr(pTI
, &pTA
);
1137 ok(hr
== S_OK
, "hr %08x\n", hr
);
1138 ok(pTA
->typekind
== TKIND_DISPATCH
, "kind %04x\n", pTA
->typekind
);
1139 ok(pTA
->cbSizeVft
== 7 * sizeof(void *), "sizevft %d\n", pTA
->cbSizeVft
);
1140 ok(pTA
->wTypeFlags
== TYPEFLAG_FDISPATCHABLE
, "typeflags %x\n", pTA
->wTypeFlags
);
1141 ok(pTA
->cFuncs
== 1, "cfuncs %d\n", pTA
->cFuncs
);
1142 ok(pTA
->cImplTypes
== 1, "cimpltypes %d\n", pTA
->cImplTypes
);
1143 ITypeInfo_ReleaseTypeAttr(pTI
, pTA
);
1145 hr
= ITypeInfo_GetRefTypeOfImplType(pTI
, 0, &href
);
1146 ok(hr
== S_OK
, "hr %08x\n", hr
);
1147 hr
= ITypeInfo_GetRefTypeInfo(pTI
, href
, &pTI_p
);
1148 ok(hr
== S_OK
, "hr %08x\n", hr
);
1149 hr
= ITypeInfo_GetTypeAttr(pTI_p
, &pTA
);
1150 ok(hr
== S_OK
, "got %08x\n", hr
);
1151 ok(IsEqualGUID(&pTA
->guid
, &IID_IDispatch
), "guid {%08x-....\n", pTA
->guid
.Data1
);
1152 ITypeInfo_ReleaseTypeAttr(pTI_p
, pTA
);
1153 ITypeInfo_Release(pTI_p
);
1154 hr
= ITypeInfo_GetFuncDesc(pTI
, 1, &pFD
);
1155 ok(hr
== TYPE_E_ELEMENTNOTFOUND
, "hr %08x\n", hr
);
1156 hr
= ITypeInfo_GetFuncDesc(pTI
, 0, &pFD
);
1157 ok(hr
== S_OK
, "hr %08x\n", hr
);
1158 ok(pFD
->memid
== 0x1c, "memid %08x\n", pFD
->memid
);
1159 ITypeInfo_ReleaseFuncDesc(pTI
, pFD
);
1160 ITypeInfo_Release(pTI
);
1163 /* ItestIF5 is dual with inherited ifaces which derive from IUnknown but not IDispatch */
1164 hr
= ITypeLib_GetTypeInfoOfGuid(pTL
, &IID_ItestIF5
, &pTI
);
1165 ok(hr
== S_OK
, "hr %08x\n", hr
);
1167 hr
= ITypeInfo_GetTypeAttr(pTI
, &pTA
);
1168 ok(hr
== S_OK
, "hr %08x\n", hr
);
1171 ok(pTA
->typekind
== TKIND_DISPATCH
, "kind %04x\n", pTA
->typekind
);
1172 ok(pTA
->cbSizeVft
== 7 * sizeof(void *), "sizevft %d\n", pTA
->cbSizeVft
);
1174 ok(pTA
->wTypeFlags
== TYPEFLAG_FDUAL
, "typeflags %x\n", pTA
->wTypeFlags
);
1176 ok(pTA
->cFuncs
== 8, "cfuncs %d\n", pTA
->cFuncs
);
1177 ok(pTA
->cImplTypes
== 1, "cimpltypes %d\n", pTA
->cImplTypes
);
1178 ITypeInfo_ReleaseTypeAttr(pTI
, pTA
);
1180 hr
= ITypeInfo_GetRefTypeOfImplType(pTI
, 0, &href
);
1181 ok(hr
== S_OK
, "hr %08x\n", hr
);
1182 hr
= ITypeInfo_GetRefTypeInfo(pTI
, href
, &pTI_p
);
1183 ok(hr
== S_OK
, "hr %08x\n", hr
);
1184 hr
= ITypeInfo_GetTypeAttr(pTI_p
, &pTA
);
1185 ok(hr
== S_OK
, "got %08x\n", hr
);
1186 ok(IsEqualGUID(&pTA
->guid
, &IID_IDispatch
), "guid {%08x-....\n", pTA
->guid
.Data1
);
1187 ITypeInfo_ReleaseTypeAttr(pTI_p
, pTA
);
1188 ITypeInfo_Release(pTI_p
);
1190 hr
= ITypeInfo_GetFuncDesc(pTI
, 6, &pFD
);
1191 ok(hr
== S_OK
, "hr %08x\n", hr
);
1192 ok(pFD
->memid
== 0x1234, "memid %08x\n", pFD
->memid
);
1193 ITypeInfo_ReleaseFuncDesc(pTI
, pFD
);
1195 ITypeInfo_Release(pTI
);
1197 /* ItestIF7 is dual with inherited ifaces which derive from Dispatch */
1198 hr
= ITypeLib_GetTypeInfoOfGuid(pTL
, &IID_ItestIF7
, &pTI
);
1199 ok(hr
== S_OK
, "hr %08x\n", hr
);
1201 hr
= ITypeInfo_GetTypeAttr(pTI
, &pTA
);
1202 ok(hr
== S_OK
, "hr %08x\n", hr
);
1203 ok(pTA
->typekind
== TKIND_DISPATCH
, "kind %04x\n", pTA
->typekind
);
1204 ok(pTA
->cbSizeVft
== 7 * sizeof(void *), "sizevft %d\n", pTA
->cbSizeVft
);
1205 ok(pTA
->wTypeFlags
== (TYPEFLAG_FDISPATCHABLE
|TYPEFLAG_FDUAL
), "typeflags %x\n", pTA
->wTypeFlags
);
1206 ok(pTA
->cFuncs
== 10, "cfuncs %d\n", pTA
->cFuncs
);
1207 ok(pTA
->cImplTypes
== 1, "cimpltypes %d\n", pTA
->cImplTypes
);
1208 ITypeInfo_ReleaseTypeAttr(pTI
, pTA
);
1210 hr
= ITypeInfo_GetRefTypeOfImplType(pTI
, 0, &href
);
1211 ok(hr
== S_OK
, "hr %08x\n", hr
);
1212 hr
= ITypeInfo_GetRefTypeInfo(pTI
, href
, &pTI_p
);
1213 ok(hr
== S_OK
, "hr %08x\n", hr
);
1214 hr
= ITypeInfo_GetTypeAttr(pTI_p
, &pTA
);
1215 ok(hr
== S_OK
, "got %08x\n", hr
);
1216 ok(IsEqualGUID(&pTA
->guid
, &IID_IDispatch
), "guid {%08x-....\n", pTA
->guid
.Data1
);
1217 ITypeInfo_ReleaseTypeAttr(pTI_p
, pTA
);
1218 ITypeInfo_Release(pTI_p
);
1220 hr
= ITypeInfo_GetFuncDesc(pTI
, 9, &pFD
);
1221 ok(hr
== S_OK
, "hr %08x\n", hr
);
1222 ok(pFD
->memid
== 0x1236, "memid %08x\n", pFD
->memid
);
1223 ITypeInfo_ReleaseFuncDesc(pTI
, pFD
);
1224 ITypeInfo_Release(pTI
);
1226 /* ItestIF10 is a syntax 2 dispinterface which doesn't derive from IUnknown */
1227 hr
= ITypeLib_GetTypeInfoOfGuid(pTL
, &DIID_ItestIF10
, &pTI
);
1228 ok(hr
== S_OK
, "hr %08x\n", hr
);
1230 hr
= ITypeInfo_GetTypeAttr(pTI
, &pTA
);
1231 ok(hr
== S_OK
, "hr %08x\n", hr
);
1232 ok(pTA
->typekind
== TKIND_DISPATCH
, "kind %04x\n", pTA
->typekind
);
1233 ok(pTA
->cbSizeVft
== 7 * sizeof(void *), "sizevft %d\n", pTA
->cbSizeVft
);
1234 ok(pTA
->wTypeFlags
== TYPEFLAG_FDISPATCHABLE
, "typeflags %x\n", pTA
->wTypeFlags
);
1236 ok(pTA
->cFuncs
== 3, "cfuncs %d\n", pTA
->cFuncs
);
1237 ok(pTA
->cImplTypes
== 1, "cimpltypes %d\n", pTA
->cImplTypes
);
1239 ITypeInfo_ReleaseTypeAttr(pTI
, pTA
);
1242 hr
= ITypeInfo_GetRefTypeOfImplType(pTI
, -1, &href
);
1243 ok(hr
== TYPE_E_ELEMENTNOTFOUND
, "hr %08x\n", hr
);
1244 hr
= ITypeInfo_GetRefTypeOfImplType(pTI
, 0, &href
);
1245 ok(hr
== S_OK
, "hr %08x\n", hr
);
1246 hr
= ITypeInfo_GetRefTypeInfo(pTI
, href
, &pTI_p
);
1247 ok(hr
== S_OK
, "hr %08x\n", hr
);
1248 hr
= ITypeInfo_GetTypeAttr(pTI_p
, &pTA
);
1249 ok(hr
== S_OK
, "got %08x\n", hr
);
1250 ok(IsEqualGUID(&pTA
->guid
, &IID_IDispatch
), "guid {%08x-....\n", pTA
->guid
.Data1
);
1251 ITypeInfo_ReleaseTypeAttr(pTI_p
, pTA
);
1252 ITypeInfo_Release(pTI_p
);
1254 /* Should have three methods */
1255 hr
= ITypeInfo_GetFuncDesc(pTI
, 3, &pFD
);
1256 ok(hr
== TYPE_E_ELEMENTNOTFOUND
, "hr %08x\n", hr
);
1257 hr
= ITypeInfo_GetFuncDesc(pTI
, 2, &pFD
);
1258 ok(hr
== S_OK
, "hr %08x\n", hr
);
1259 ok(pFD
->memid
== 0x60010000, "memid %08x\n", pFD
->memid
);
1260 ok(pFD
->oVft
== 2 * sizeof(void *), "oVft %d\n", pFD
->oVft
);
1261 ITypeInfo_ReleaseFuncDesc(pTI
, pFD
);
1263 ITypeInfo_Release(pTI
);
1265 /* ItestIF11 is a syntax 2 dispinterface which derives from IDispatch */
1266 hr
= ITypeLib_GetTypeInfoOfGuid(pTL
, &DIID_ItestIF11
, &pTI
);
1267 ok(hr
== S_OK
, "hr %08x\n", hr
);
1269 hr
= ITypeInfo_GetTypeAttr(pTI
, &pTA
);
1270 ok(hr
== S_OK
, "hr %08x\n", hr
);
1271 ok(pTA
->typekind
== TKIND_DISPATCH
, "kind %04x\n", pTA
->typekind
);
1272 ok(pTA
->cbSizeVft
== 7 * sizeof(void *), "sizevft %d\n", pTA
->cbSizeVft
);
1273 ok(pTA
->wTypeFlags
== TYPEFLAG_FDISPATCHABLE
, "typeflags %x\n", pTA
->wTypeFlags
);
1275 ok(pTA
->cFuncs
== 10, "cfuncs %d\n", pTA
->cFuncs
);
1276 ok(pTA
->cImplTypes
== 1, "cimpltypes %d\n", pTA
->cImplTypes
);
1278 ITypeInfo_ReleaseTypeAttr(pTI
, pTA
);
1281 hr
= ITypeInfo_GetRefTypeOfImplType(pTI
, 0, &href
);
1282 ok(hr
== S_OK
, "hr %08x\n", hr
);
1283 hr
= ITypeInfo_GetRefTypeInfo(pTI
, href
, &pTI_p
);
1284 ok(hr
== S_OK
, "hr %08x\n", hr
);
1285 hr
= ITypeInfo_GetTypeAttr(pTI_p
, &pTA
);
1286 ok(hr
== S_OK
, "got %08x\n", hr
);
1287 ok(IsEqualGUID(&pTA
->guid
, &IID_IDispatch
), "guid {%08x-....\n", pTA
->guid
.Data1
);
1288 ITypeInfo_ReleaseTypeAttr(pTI_p
, pTA
);
1289 ITypeInfo_Release(pTI_p
);
1291 /* Should have ten methods */
1292 hr
= ITypeInfo_GetFuncDesc(pTI
, 10, &pFD
);
1293 ok(hr
== TYPE_E_ELEMENTNOTFOUND
, "hr %08x\n", hr
);
1294 hr
= ITypeInfo_GetFuncDesc(pTI
, 9, &pFD
);
1295 ok(hr
== S_OK
, "hr %08x\n", hr
);
1296 ok(pFD
->memid
== 0x1236, "memid %08x\n", pFD
->memid
);
1297 ok(pFD
->oVft
== 9 * sizeof(void *), "oVft %d\n", pFD
->oVft
);
1299 /* first argument to 10th function is an HREFTYPE from the impl type */
1300 ok(pFD
->cParams
== 1, "cParams %i\n", pFD
->cParams
);
1301 ok(pFD
->lprgelemdescParam
[0].tdesc
.vt
== VT_USERDEFINED
,
1302 "vt 0x%x\n", pFD
->lprgelemdescParam
[0].tdesc
.vt
);
1303 href
= U(pFD
->lprgelemdescParam
[0].tdesc
).hreftype
;
1304 ok((href
& 0xff000000) == 0x04000000, "href 0x%08x\n", href
);
1305 hr
= ITypeInfo_GetRefTypeInfo(pTI
, href
, &pTI_p
);
1306 ok(hr
== S_OK
, "hr %08x\n", hr
);
1307 if (SUCCEEDED(hr
)) ITypeInfo_Release(pTI_p
);
1308 ITypeInfo_ReleaseFuncDesc(pTI
, pFD
);
1310 ITypeInfo_Release(pTI
);
1313 /* ItestIF2 is an interface which derives from IUnknown */
1314 hr
= ITypeLib_GetTypeInfoOfGuid(pTL
, &IID_ItestIF2
, &pTI
);
1315 ok(hr
== S_OK
, "hr %08x\n", hr
);
1317 hr
= ITypeInfo_GetTypeAttr(pTI
, &pTA
);
1318 ok(hr
== S_OK
, "hr %08x\n", hr
);
1319 ok(pTA
->typekind
== TKIND_INTERFACE
, "kind %04x\n", pTA
->typekind
);
1320 ok(pTA
->cbSizeVft
== 6 * sizeof(void *), "sizevft %d\n", pTA
->cbSizeVft
);
1321 ok(pTA
->wTypeFlags
== 0, "typeflags %x\n", pTA
->wTypeFlags
);
1323 ok(pTA
->cFuncs
== 1, "cfuncs %d\n", pTA
->cFuncs
);
1324 ok(pTA
->cImplTypes
== 1, "cimpltypes %d\n", pTA
->cImplTypes
);
1326 ITypeInfo_ReleaseTypeAttr(pTI
, pTA
);
1329 /* Should have one method */
1330 hr
= ITypeInfo_GetFuncDesc(pTI
, 1, &pFD
);
1331 ok(hr
== TYPE_E_ELEMENTNOTFOUND
, "hr %08x\n", hr
);
1332 hr
= ITypeInfo_GetFuncDesc(pTI
, 0, &pFD
);
1333 ok(hr
== S_OK
, "hr %08x\n", hr
);
1334 ok(pFD
->memid
== 0x60020000, "memid %08x\n", pFD
->memid
);
1335 ok(pFD
->oVft
== 5 * sizeof(void *), "oVft %d\n", pFD
->oVft
);
1336 ITypeInfo_ReleaseFuncDesc(pTI
, pFD
);
1338 ITypeInfo_Release(pTI
);
1340 ITypeLib_Release(pTL
);
1345 static void test_CreateTypeLib(void) {
1346 static const WCHAR stdoleW
[] = {'s','t','d','o','l','e','2','.','t','l','b',0};
1347 static OLECHAR typelibW
[] = {'t','y','p','e','l','i','b',0};
1348 static OLECHAR helpfileW
[] = {'C',':','\\','b','o','g','u','s','.','h','l','p',0};
1349 static OLECHAR interface1W
[] = {'i','n','t','e','r','f','a','c','e','1',0};
1350 static OLECHAR interface2W
[] = {'i','n','t','e','r','f','a','c','e','2',0};
1351 static OLECHAR interface3W
[] = {'i','n','t','e','r','f','a','c','e','3',0};
1352 static OLECHAR dualW
[] = {'d','u','a','l',0};
1353 static OLECHAR coclassW
[] = {'c','o','c','l','a','s','s',0};
1354 static WCHAR defaultW
[] = {'d','e','f','a','u','l','t',0x3213,0};
1355 static WCHAR defaultQW
[] = {'d','e','f','a','u','l','t','?',0};
1356 static OLECHAR func1W
[] = {'f','u','n','c','1',0};
1357 static OLECHAR func2W
[] = {'f','u','n','c','2',0};
1358 static OLECHAR prop1W
[] = {'P','r','o','p','1',0};
1359 static OLECHAR param1W
[] = {'p','a','r','a','m','1',0};
1360 static OLECHAR param2W
[] = {'p','a','r','a','m','2',0};
1361 static OLECHAR asdfW
[] = {'A','s','d','f',0};
1362 static OLECHAR
*names1
[] = {func1W
, param1W
, param2W
};
1363 static OLECHAR
*names2
[] = {func2W
, param1W
, param2W
};
1364 static OLECHAR
*propname
[] = {prop1W
, param1W
};
1365 static const GUID custguid
= {0xbf611abe,0x5b38,0x11df,{0x91,0x5c,0x08,0x02,0x79,0x79,0x94,0x70}};
1366 static const GUID bogusguid
= {0xbf611abe,0x5b38,0x11df,{0x91,0x5c,0x08,0x02,0x79,0x79,0x94,0x71}};
1368 char filename
[MAX_PATH
];
1369 WCHAR filenameW
[MAX_PATH
];
1370 ICreateTypeLib2
*createtl
;
1371 ICreateTypeInfo
*createti
;
1372 ICreateTypeInfo2
*createti2
;
1373 ITypeLib
*tl
, *stdole
;
1374 ITypeInfo
*interface1
, *interface2
, *dual
, *unknown
, *dispatch
, *ti
;
1376 FUNCDESC funcdesc
, *pfuncdesc
;
1377 ELEMDESC elemdesc
[5], *edesc
;
1378 PARAMDESCEX paramdescex
;
1379 TYPEDESC typedesc1
, typedesc2
;
1383 BSTR name
, docstring
, helpfile
;
1390 trace("CreateTypeLib tests\n");
1392 hres
= LoadTypeLib(stdoleW
, &stdole
);
1393 ok(hres
== S_OK
, "got %08x\n", hres
);
1395 hres
= ITypeLib_GetTypeInfoOfGuid(stdole
, &IID_IUnknown
, &unknown
);
1396 ok(hres
== S_OK
, "got %08x\n", hres
);
1398 hres
= ITypeLib_GetTypeInfoOfGuid(stdole
, &IID_IDispatch
, &dispatch
);
1399 ok(hres
== S_OK
, "got %08x\n", hres
);
1401 GetTempFileNameA(".", "tlb", 0, filename
);
1402 MultiByteToWideChar(CP_ACP
, 0, filename
, -1, filenameW
, MAX_PATH
);
1404 hres
= CreateTypeLib2(SYS_WIN32
, filenameW
, &createtl
);
1405 ok(hres
== S_OK
, "got %08x\n", hres
);
1407 hres
= ICreateTypeLib_QueryInterface(createtl
, &IID_ITypeLib
, (void**)&tl
);
1408 ok(hres
== S_OK
, "got %08x\n", hres
);
1410 hres
= ITypeLib_GetTypeInfo(tl
, 0, NULL
);
1411 ok(hres
== E_INVALIDARG
, "got 0x%08x\n", hres
);
1413 hres
= ITypeLib_GetTypeInfoType(tl
, 0, &kind
);
1414 ok(hres
== TYPE_E_ELEMENTNOTFOUND
, "got 0x%08x\n", hres
);
1416 hres
= ITypeLib_GetTypeInfoType(tl
, 0, NULL
);
1417 ok(hres
== E_INVALIDARG
, "got 0x%08x\n", hres
);
1419 hres
= ITypeLib_GetTypeInfoType(tl
, 0, NULL
);
1420 ok(hres
== E_INVALIDARG
, "got 0x%08x\n", hres
);
1422 hres
= ITypeLib_GetLibAttr(tl
, NULL
);
1423 ok(hres
== E_INVALIDARG
, "got %08x\n", hres
);
1425 hres
= ITypeLib_GetLibAttr(tl
, &libattr
);
1426 ok(hres
== S_OK
, "got %08x\n", hres
);
1428 ok(libattr
->syskind
== SYS_WIN32
, "syskind = %d\n", libattr
->syskind
);
1429 ok(libattr
->wMajorVerNum
== 0, "wMajorVer = %d\n", libattr
->wMajorVerNum
);
1430 ok(libattr
->wMinorVerNum
== 0, "wMinorVerNum = %d\n", libattr
->wMinorVerNum
);
1431 ok(libattr
->wLibFlags
== 0, "wLibFlags = %d\n", libattr
->wLibFlags
);
1433 ITypeLib_ReleaseTLibAttr(tl
, libattr
);
1435 name
= (BSTR
)0xdeadbeef;
1436 hres
= ITypeLib_GetDocumentation(tl
, -1, &name
, &docstring
, &helpcontext
, &helpfile
);
1437 ok(hres
== S_OK
, "got %08x\n", hres
);
1438 ok(name
== NULL
, "name != NULL\n");
1439 ok(docstring
== NULL
, "docstring != NULL\n");
1440 ok(helpcontext
== 0, "helpcontext != 0\n");
1441 ok(helpfile
== NULL
, "helpfile != NULL\n");
1443 hres
= ITypeLib_GetDocumentation(tl
, 0, &name
, NULL
, NULL
, NULL
);
1444 ok(hres
== TYPE_E_ELEMENTNOTFOUND
, "got %08x\n", hres
);
1446 hres
= ICreateTypeLib_SetName(createtl
, typelibW
);
1447 ok(hres
== S_OK
, "got %08x\n", hres
);
1449 hres
= ICreateTypeLib_SetHelpFileName(createtl
, helpfileW
);
1450 ok(hres
== S_OK
, "got %08x\n", hres
);
1452 hres
= ITypeLib_GetDocumentation(tl
, -1, NULL
, NULL
, NULL
, NULL
);
1453 ok(hres
== S_OK
, "got %08x\n", hres
);
1455 hres
= ITypeLib_GetDocumentation(tl
, -1, &name
, NULL
, NULL
, &helpfile
);
1456 ok(hres
== S_OK
, "got %08x\n", hres
);
1457 ok(!memcmp(name
, typelibW
, sizeof(typelibW
)), "name = %s\n", wine_dbgstr_w(name
));
1458 ok(!memcmp(helpfile
, helpfileW
, sizeof(helpfileW
)), "helpfile = %s\n", wine_dbgstr_w(helpfile
));
1460 SysFreeString(name
);
1461 SysFreeString(helpfile
);
1463 /* invalid parameters */
1464 hres
= ICreateTypeLib_CreateTypeInfo(createtl
, NULL
, TKIND_INTERFACE
, &createti
);
1465 ok(hres
== E_INVALIDARG
, "got %08x\n", hres
);
1467 hres
= ICreateTypeLib_CreateTypeInfo(createtl
, interface1W
, TKIND_INTERFACE
, NULL
);
1468 ok(hres
== E_INVALIDARG
, "got %08x\n", hres
);
1470 hres
= ICreateTypeLib_CreateTypeInfo(createtl
, NULL
, TKIND_INTERFACE
, NULL
);
1471 ok(hres
== E_INVALIDARG
, "got %08x\n", hres
);
1473 hres
= ICreateTypeLib_CreateTypeInfo(createtl
, interface1W
, TKIND_INTERFACE
, &createti
);
1474 ok(hres
== S_OK
, "got %08x\n", hres
);
1476 hres
= ICreateTypeInfo_QueryInterface(createti
, &IID_ITypeInfo
, (void**)&interface1
);
1477 ok(hres
== S_OK
, "got %08x\n", hres
);
1479 hres
= ITypeLib_GetDocumentation(tl
, 0, &name
, NULL
, NULL
, NULL
);
1480 ok(hres
== S_OK
, "got %08x\n", hres
);
1481 ok(!memcmp(name
, interface1W
, sizeof(interface1W
)), "name = %s\n", wine_dbgstr_w(name
));
1483 SysFreeString(name
);
1485 ITypeLib_Release(tl
);
1487 name
= (BSTR
)0xdeadbeef;
1488 helpfile
= (BSTR
)0xdeadbeef;
1489 hres
= ITypeInfo_GetDocumentation(interface1
, -1, &name
, &docstring
, &helpcontext
, &helpfile
);
1490 ok(hres
== S_OK
, "got %08x\n", hres
);
1491 ok(!memcmp(name
, interface1W
, sizeof(interface1W
)), "name = %s\n", wine_dbgstr_w(name
));
1492 ok(docstring
== NULL
, "docstring != NULL\n");
1493 ok(helpcontext
== 0, "helpcontext != 0\n");
1494 ok(!memcmp(helpfile
, helpfileW
, sizeof(helpfileW
)), "helpfile = %s\n", wine_dbgstr_w(helpfile
));
1496 SysFreeString(name
);
1497 SysFreeString(helpfile
);
1499 hres
= ITypeInfo_GetDocumentation(interface1
, 0, &name
, NULL
, NULL
, NULL
);
1500 ok(hres
== TYPE_E_ELEMENTNOTFOUND
, "got %08x\n", hres
);
1502 hres
= ITypeInfo_GetRefTypeInfo(interface1
, 0, NULL
);
1503 ok(hres
== E_INVALIDARG
, "got %08x\n", hres
);
1506 hres
= ICreateTypeInfo_LayOut(createti
);
1507 ok(hres
== S_OK
, "got %08x\n", hres
);
1509 hres
= ICreateTypeInfo_AddRefTypeInfo(createti
, NULL
, &hreftype
);
1510 ok(hres
== E_INVALIDARG
, "got %08x\n", hres
);
1512 hres
= ICreateTypeInfo_AddRefTypeInfo(createti
, unknown
, NULL
);
1513 ok(hres
== E_INVALIDARG
, "got %08x\n", hres
);
1515 hres
= ICreateTypeInfo_AddRefTypeInfo(createti
, unknown
, &hreftype
);
1516 ok(hres
== S_OK
, "got %08x\n", hres
);
1518 skip("Skipping some tests\n");
1522 hres
= ICreateTypeInfo_AddImplType(createti
, 1, hreftype
);
1523 ok(hres
== TYPE_E_ELEMENTNOTFOUND
, "got %08x\n", hres
);
1525 hres
= ICreateTypeInfo_AddImplType(createti
, 0, hreftype
);
1526 ok(hres
== S_OK
, "got %08x\n", hres
);
1528 hres
= ITypeInfo_GetRefTypeOfImplType(interface1
, 0, &hreftype
);
1529 ok(hres
== S_OK
, "got %08x\n", hres
);
1530 ok(hreftype
== 3, "hreftype = %d\n", hreftype
);
1532 hres
= ITypeInfo_GetRefTypeOfImplType(interface1
, -1, &hreftype
);
1533 ok(hres
== TYPE_E_ELEMENTNOTFOUND
, "got %08x\n", hres
);
1535 ICreateTypeInfo_QueryInterface(createti
, &IID_ITypeInfo2
, (void**)&ti2
);
1537 memset(&funcdesc
, 0, sizeof(FUNCDESC
));
1538 funcdesc
.funckind
= FUNC_PUREVIRTUAL
;
1539 funcdesc
.invkind
= INVOKE_PROPERTYGET
;
1540 funcdesc
.callconv
= CC_STDCALL
;
1541 funcdesc
.elemdescFunc
.tdesc
.vt
= VT_BSTR
;
1542 U(funcdesc
.elemdescFunc
).idldesc
.wIDLFlags
= IDLFLAG_NONE
;
1544 hres
= ICreateTypeInfo_AddFuncDesc(createti
, 0, NULL
);
1545 ok(hres
== E_INVALIDARG
, "got %08x\n", hres
);
1547 hres
= ICreateTypeInfo_AddFuncDesc(createti
, 1, &funcdesc
);
1548 ok(hres
== TYPE_E_ELEMENTNOTFOUND
, "got %08x\n", hres
);
1550 hres
= ICreateTypeInfo_AddFuncDesc(createti
, 0, &funcdesc
);
1551 ok(hres
== S_OK
, "got %08x\n", hres
);
1553 hres
= ITypeInfo2_GetFuncDesc(ti2
, 0, NULL
);
1554 ok(hres
== E_INVALIDARG
, "got %08x\n", hres
);
1556 hres
= ITypeInfo2_GetFuncDesc(ti2
, 1, &pfuncdesc
);
1557 ok(hres
== TYPE_E_ELEMENTNOTFOUND
, "got %08x\n", hres
);
1559 hres
= ITypeInfo2_GetFuncDesc(ti2
, 0, &pfuncdesc
);
1560 ok(hres
== S_OK
, "got %08x\n", hres
);
1562 ok(pfuncdesc
->memid
== 0, "got %x\n", pfuncdesc
->memid
);
1563 ok(pfuncdesc
->lprgscode
== NULL
, "got %p\n", pfuncdesc
->lprgscode
);
1564 ok(pfuncdesc
->lprgelemdescParam
== NULL
, "got %p\n", pfuncdesc
->lprgelemdescParam
);
1565 ok(pfuncdesc
->funckind
== FUNC_PUREVIRTUAL
, "got 0x%x\n", pfuncdesc
->funckind
);
1566 ok(pfuncdesc
->invkind
== INVOKE_PROPERTYGET
, "got 0x%x\n", pfuncdesc
->invkind
);
1567 ok(pfuncdesc
->callconv
== CC_STDCALL
, "got 0x%x\n", pfuncdesc
->callconv
);
1568 ok(pfuncdesc
->cParams
== 0, "got %d\n", pfuncdesc
->cParams
);
1569 ok(pfuncdesc
->cParamsOpt
== 0, "got %d\n", pfuncdesc
->cParamsOpt
);
1570 todo_wine
ok(pfuncdesc
->oVft
== 12 ||
1571 broken(pfuncdesc
->oVft
== 24) /* xp64 */,
1572 "got %d\n", pfuncdesc
->oVft
);
1573 ok(pfuncdesc
->cScodes
== 0, "got %d\n", pfuncdesc
->cScodes
);
1574 ok(pfuncdesc
->elemdescFunc
.tdesc
.vt
== VT_BSTR
, "got %d\n", pfuncdesc
->elemdescFunc
.tdesc
.vt
);
1575 ok(pfuncdesc
->wFuncFlags
== 0, "got 0x%x\n", pfuncdesc
->wFuncFlags
);
1577 ITypeInfo2_ReleaseFuncDesc(ti2
, pfuncdesc
);
1579 hres
= ICreateTypeInfo_SetFuncHelpContext(createti
, 0, 0xabcdefab);
1580 ok(hres
== S_OK
, "got %08x\n", hres
);
1582 funcdesc
.invkind
= INVOKE_PROPERTYPUT
;
1583 hres
= ICreateTypeInfo_AddFuncDesc(createti
, 1, &funcdesc
);
1584 ok(hres
== TYPE_E_INCONSISTENTPROPFUNCS
, "got %08x\n", hres
);
1586 funcdesc
.invkind
= INVOKE_PROPERTYPUTREF
;
1587 hres
= ICreateTypeInfo_AddFuncDesc(createti
, 1, &funcdesc
);
1588 ok(hres
== TYPE_E_INCONSISTENTPROPFUNCS
, "got %08x\n", hres
);
1590 elemdesc
[0].tdesc
.vt
= VT_BSTR
;
1591 U(elemdesc
[0]).idldesc
.dwReserved
= 0;
1592 U(elemdesc
[0]).idldesc
.wIDLFlags
= IDLFLAG_FIN
;
1594 funcdesc
.lprgelemdescParam
= elemdesc
;
1595 funcdesc
.invkind
= INVOKE_PROPERTYPUT
;
1596 funcdesc
.cParams
= 1;
1597 funcdesc
.elemdescFunc
.tdesc
.vt
= VT_VOID
;
1599 hres
= ICreateTypeInfo_AddFuncDesc(createti
, 1, &funcdesc
);
1600 ok(hres
== S_OK
, "got %08x\n", hres
);
1602 hres
= ICreateTypeInfo_SetFuncHelpContext(createti
, 1, 0xabcdefab);
1603 ok(hres
== S_OK
, "got %08x\n", hres
);
1605 hres
= ICreateTypeInfo_SetFuncAndParamNames(createti
, 0, propname
, 0);
1606 ok(hres
== TYPE_E_ELEMENTNOTFOUND
, "got %08x\n", hres
);
1608 hres
= ICreateTypeInfo_SetFuncAndParamNames(createti
, 0, NULL
, 1);
1609 ok(hres
== E_INVALIDARG
, "got %08x\n", hres
);
1611 hres
= ICreateTypeInfo_SetFuncAndParamNames(createti
, 0, propname
, 1);
1612 ok(hres
== S_OK
, "got %08x\n", hres
);
1614 hres
= ICreateTypeInfo_SetFuncAndParamNames(createti
, 1, propname
, 1);
1615 ok(hres
== S_OK
, "got %08x\n", hres
);
1617 hres
= ICreateTypeInfo_SetFuncAndParamNames(createti
, 1, propname
, 2);
1618 ok(hres
== TYPE_E_ELEMENTNOTFOUND
, "got %08x\n", hres
);
1620 hres
= ITypeInfo2_GetFuncDesc(ti2
, 1, &pfuncdesc
);
1621 ok(hres
== S_OK
, "got %08x\n", hres
);
1623 ok(pfuncdesc
->memid
== 0, "got %x\n", pfuncdesc
->memid
);
1624 ok(pfuncdesc
->lprgscode
== NULL
, "got %p\n", pfuncdesc
->lprgscode
);
1625 ok(pfuncdesc
->lprgelemdescParam
!= NULL
, "got %p\n", pfuncdesc
->lprgelemdescParam
);
1626 ok(pfuncdesc
->funckind
== FUNC_PUREVIRTUAL
, "got 0x%x\n", pfuncdesc
->funckind
);
1627 ok(pfuncdesc
->invkind
== INVOKE_PROPERTYPUT
, "got 0x%x\n", pfuncdesc
->invkind
);
1628 ok(pfuncdesc
->callconv
== CC_STDCALL
, "got 0x%x\n", pfuncdesc
->callconv
);
1629 ok(pfuncdesc
->cParams
== 1, "got %d\n", pfuncdesc
->cParams
);
1630 ok(pfuncdesc
->cParamsOpt
== 0, "got %d\n", pfuncdesc
->cParamsOpt
);
1631 todo_wine
ok(pfuncdesc
->oVft
== 16 ||
1632 broken(pfuncdesc
->oVft
== 28) /* xp64 */,
1633 "got %d\n", pfuncdesc
->oVft
);
1634 ok(pfuncdesc
->cScodes
== 0, "got %d\n", pfuncdesc
->cScodes
);
1635 ok(pfuncdesc
->elemdescFunc
.tdesc
.vt
== VT_VOID
, "got %d\n", pfuncdesc
->elemdescFunc
.tdesc
.vt
);
1636 ok(pfuncdesc
->wFuncFlags
== 0, "got 0x%x\n", pfuncdesc
->wFuncFlags
);
1638 edesc
= pfuncdesc
->lprgelemdescParam
;
1639 ok(edesc
->tdesc
.vt
== VT_BSTR
, "got: %d\n", edesc
->tdesc
.vt
);
1640 ok(U(*edesc
).idldesc
.wIDLFlags
== IDLFLAG_FIN
, "got: %x\n", U(*edesc
).idldesc
.wIDLFlags
);
1642 ITypeInfo2_ReleaseFuncDesc(ti2
, pfuncdesc
);
1645 funcdesc
.invkind
= INVOKE_PROPERTYPUTREF
;
1646 hres
= ICreateTypeInfo_AddFuncDesc(createti
, 0, &funcdesc
);
1647 ok(hres
== S_OK
, "got %08x\n", hres
);
1649 hres
= ICreateTypeInfo_SetFuncHelpContext(createti
, 0, 0xabcdefab);
1650 ok(hres
== S_OK
, "got %08x\n", hres
);
1652 hres
= ICreateTypeInfo_SetFuncHelpContext(createti
, 0, 0x201);
1653 ok(hres
== S_OK
, "got %08x\n", hres
);
1656 funcdesc
.lprgelemdescParam
= NULL
;
1657 funcdesc
.invkind
= INVOKE_FUNC
;
1658 funcdesc
.cParams
= 0;
1659 hres
= ICreateTypeInfo_AddFuncDesc(createti
, 1, &funcdesc
);
1660 ok(hres
== S_OK
, "got %08x\n", hres
);
1662 hres
= ITypeInfo2_GetFuncDesc(ti2
, 1, &pfuncdesc
);
1663 ok(hres
== S_OK
, "got %08x\n", hres
);
1665 ok(pfuncdesc
->memid
== 1, "got %d\n", pfuncdesc
->memid
);
1666 ok(pfuncdesc
->lprgscode
== NULL
, "got %p\n", pfuncdesc
->lprgscode
);
1667 ok(pfuncdesc
->lprgelemdescParam
== NULL
, "got %p\n", pfuncdesc
->lprgelemdescParam
);
1668 ok(pfuncdesc
->funckind
== FUNC_PUREVIRTUAL
, "got 0x%x\n", pfuncdesc
->funckind
);
1669 ok(pfuncdesc
->invkind
== INVOKE_FUNC
, "got 0x%x\n", pfuncdesc
->invkind
);
1670 ok(pfuncdesc
->callconv
== CC_STDCALL
, "got 0x%x\n", pfuncdesc
->callconv
);
1671 ok(pfuncdesc
->cParams
== 0, "got %d\n", pfuncdesc
->cParams
);
1672 ok(pfuncdesc
->cParamsOpt
== 0, "got %d\n", pfuncdesc
->cParamsOpt
);
1673 todo_wine
ok(pfuncdesc
->oVft
== 16 ||
1674 broken(pfuncdesc
->oVft
== 28), /* xp64 */
1675 "got %d\n", pfuncdesc
->oVft
);
1676 ok(pfuncdesc
->cScodes
== 0, "got %d\n", pfuncdesc
->cScodes
);
1677 ok(pfuncdesc
->elemdescFunc
.tdesc
.vt
== VT_VOID
, "got %d\n", pfuncdesc
->elemdescFunc
.tdesc
.vt
);
1678 ok(pfuncdesc
->wFuncFlags
== 0, "got 0x%x\n", pfuncdesc
->wFuncFlags
);
1680 ITypeInfo2_ReleaseFuncDesc(ti2
, pfuncdesc
);
1682 funcdesc
.memid
= MEMBERID_NIL
;
1683 hres
= ICreateTypeInfo_AddFuncDesc(createti
, 1, &funcdesc
);
1684 ok(hres
== S_OK
, "got %08x\n", hres
);
1686 elemdesc
[0].tdesc
.vt
= VT_PTR
;
1687 U(elemdesc
[0].tdesc
).lptdesc
= &typedesc1
;
1688 typedesc1
.vt
= VT_BSTR
;
1689 funcdesc
.cParams
= 1;
1690 funcdesc
.lprgelemdescParam
= elemdesc
;
1691 hres
= ICreateTypeInfo_AddFuncDesc(createti
, 4, &funcdesc
);
1692 ok(hres
== S_OK
, "got %08x\n", hres
);
1694 hres
= ITypeInfo2_GetFuncDesc(ti2
, 4, &pfuncdesc
);
1695 ok(hres
== S_OK
, "got %08x\n", hres
);
1697 ok(pfuncdesc
->memid
== 0x60010004, "got %x\n", pfuncdesc
->memid
);
1698 ok(pfuncdesc
->lprgscode
== NULL
, "got %p\n", pfuncdesc
->lprgscode
);
1699 ok(pfuncdesc
->lprgelemdescParam
!= NULL
, "got %p\n", pfuncdesc
->lprgelemdescParam
);
1700 ok(pfuncdesc
->funckind
== FUNC_PUREVIRTUAL
, "got 0x%x\n", pfuncdesc
->funckind
);
1701 ok(pfuncdesc
->invkind
== INVOKE_FUNC
, "got 0x%x\n", pfuncdesc
->invkind
);
1702 ok(pfuncdesc
->callconv
== CC_STDCALL
, "got 0x%x\n", pfuncdesc
->callconv
);
1703 ok(pfuncdesc
->cParams
== 1, "got %d\n", pfuncdesc
->cParams
);
1704 ok(pfuncdesc
->cParamsOpt
== 0, "got %d\n", pfuncdesc
->cParamsOpt
);
1705 todo_wine
ok(pfuncdesc
->oVft
== 28 ||
1706 broken(pfuncdesc
->oVft
== 40) /* xp64 */,
1707 "got %d\n", pfuncdesc
->oVft
);
1708 ok(pfuncdesc
->cScodes
== 0, "got %d\n", pfuncdesc
->cScodes
);
1709 ok(pfuncdesc
->elemdescFunc
.tdesc
.vt
== VT_VOID
, "got %d\n", pfuncdesc
->elemdescFunc
.tdesc
.vt
);
1710 ok(pfuncdesc
->wFuncFlags
== 0, "got 0x%x\n", pfuncdesc
->wFuncFlags
);
1712 edesc
= pfuncdesc
->lprgelemdescParam
;
1713 ok(edesc
->tdesc
.vt
== VT_PTR
, "got: %d\n", edesc
->tdesc
.vt
);
1714 ok(U(*edesc
).paramdesc
.wParamFlags
== PARAMFLAG_FIN
, "got: 0x%x\n", U(*edesc
).paramdesc
.wParamFlags
);
1715 ok(U(*edesc
).paramdesc
.pparamdescex
== NULL
, "got: %p\n", U(*edesc
).paramdesc
.pparamdescex
);
1716 ok(U(edesc
->tdesc
).lptdesc
!= NULL
, "got: %p\n", U(edesc
->tdesc
).lptdesc
);
1717 ok(U(edesc
->tdesc
).lptdesc
->vt
== VT_BSTR
, "got: %d\n", U(edesc
->tdesc
).lptdesc
->vt
);
1719 ITypeInfo2_ReleaseFuncDesc(ti2
, pfuncdesc
);
1721 U(elemdesc
[0].tdesc
).lptdesc
= &typedesc2
;
1722 typedesc2
.vt
= VT_PTR
;
1723 U(typedesc2
).lptdesc
= &typedesc1
;
1724 hres
= ICreateTypeInfo_AddFuncDesc(createti
, 4, &funcdesc
);
1725 ok(hres
== S_OK
, "got %08x\n", hres
);
1727 hres
= ITypeInfo2_GetFuncDesc(ti2
, 4, &pfuncdesc
);
1728 ok(hres
== S_OK
, "got %08x\n", hres
);
1730 ok(pfuncdesc
->memid
== 0x60010007, "got %x\n", pfuncdesc
->memid
);
1731 ok(pfuncdesc
->lprgscode
== NULL
, "got %p\n", pfuncdesc
->lprgscode
);
1732 ok(pfuncdesc
->lprgelemdescParam
!= NULL
, "got %p\n", pfuncdesc
->lprgelemdescParam
);
1733 ok(pfuncdesc
->funckind
== FUNC_PUREVIRTUAL
, "got 0x%x\n", pfuncdesc
->funckind
);
1734 ok(pfuncdesc
->invkind
== INVOKE_FUNC
, "got 0x%x\n", pfuncdesc
->invkind
);
1735 ok(pfuncdesc
->callconv
== CC_STDCALL
, "got 0x%x\n", pfuncdesc
->callconv
);
1736 ok(pfuncdesc
->cParams
== 1, "got %d\n", pfuncdesc
->cParams
);
1737 ok(pfuncdesc
->cParamsOpt
== 0, "got %d\n", pfuncdesc
->cParamsOpt
);
1738 todo_wine
ok(pfuncdesc
->oVft
== 28 ||
1739 broken(pfuncdesc
->oVft
== 40) /* xp64 */,
1740 "got %d\n", pfuncdesc
->oVft
);
1741 ok(pfuncdesc
->cScodes
== 0, "got %d\n", pfuncdesc
->cScodes
);
1742 ok(pfuncdesc
->elemdescFunc
.tdesc
.vt
== VT_VOID
, "got %d\n", pfuncdesc
->elemdescFunc
.tdesc
.vt
);
1743 ok(pfuncdesc
->wFuncFlags
== 0, "got 0x%x\n", pfuncdesc
->wFuncFlags
);
1745 edesc
= pfuncdesc
->lprgelemdescParam
;
1746 ok(edesc
->tdesc
.vt
== VT_PTR
, "got: %d\n", edesc
->tdesc
.vt
);
1747 ok(U(*edesc
).paramdesc
.wParamFlags
== PARAMFLAG_FIN
, "got: 0x%x\n", U(*edesc
).paramdesc
.wParamFlags
);
1748 ok(U(*edesc
).paramdesc
.pparamdescex
== NULL
, "got: %p\n", U(*edesc
).paramdesc
.pparamdescex
);
1749 ok(U(edesc
->tdesc
).lptdesc
!= NULL
, "got: %p\n", U(edesc
->tdesc
).lptdesc
);
1750 ok(U(edesc
->tdesc
).lptdesc
->vt
== VT_PTR
, "got: %d\n", U(edesc
->tdesc
).lptdesc
->vt
);
1751 ok(U(*U(edesc
->tdesc
).lptdesc
).lptdesc
!= NULL
, "got: %p\n", U(*U(edesc
->tdesc
).lptdesc
).lptdesc
);
1752 ok(U(*U(edesc
->tdesc
).lptdesc
).lptdesc
->vt
== VT_BSTR
, "got: %d\n", U(*U(edesc
->tdesc
).lptdesc
).lptdesc
->vt
);
1754 ITypeInfo2_ReleaseFuncDesc(ti2
, pfuncdesc
);
1756 elemdesc
[0].tdesc
.vt
= VT_INT
;
1757 U(elemdesc
[0]).paramdesc
.wParamFlags
= PARAMFLAG_FHASDEFAULT
;
1758 U(elemdesc
[0]).paramdesc
.pparamdescex
= ¶mdescex
;
1759 V_VT(¶mdescex
.varDefaultValue
) = VT_INT
;
1760 V_INT(¶mdescex
.varDefaultValue
) = 0x123;
1761 hres
= ICreateTypeInfo_AddFuncDesc(createti
, 3, &funcdesc
);
1762 ok(hres
== S_OK
, "got %08x\n", hres
);
1764 hres
= ITypeInfo2_GetFuncDesc(ti2
, 3, &pfuncdesc
);
1765 ok(hres
== S_OK
, "got %08x\n", hres
);
1767 ok(pfuncdesc
->memid
== 0x60010003, "got %x\n", pfuncdesc
->memid
);
1768 ok(pfuncdesc
->lprgscode
== NULL
, "got %p\n", pfuncdesc
->lprgscode
);
1769 ok(pfuncdesc
->lprgelemdescParam
!= NULL
, "got %p\n", pfuncdesc
->lprgelemdescParam
);
1770 ok(pfuncdesc
->funckind
== FUNC_PUREVIRTUAL
, "got 0x%x\n", pfuncdesc
->funckind
);
1771 ok(pfuncdesc
->invkind
== INVOKE_FUNC
, "got 0x%x\n", pfuncdesc
->invkind
);
1772 ok(pfuncdesc
->callconv
== CC_STDCALL
, "got 0x%x\n", pfuncdesc
->callconv
);
1773 ok(pfuncdesc
->cParams
== 1, "got %d\n", pfuncdesc
->cParams
);
1774 ok(pfuncdesc
->cParamsOpt
== 0, "got %d\n", pfuncdesc
->cParamsOpt
);
1775 todo_wine
ok(pfuncdesc
->oVft
== 24 ||
1776 broken(pfuncdesc
->oVft
== 36) /* xp64 */,
1777 "got %d\n", pfuncdesc
->oVft
);
1778 ok(pfuncdesc
->cScodes
== 0, "got %d\n", pfuncdesc
->cScodes
);
1779 ok(pfuncdesc
->elemdescFunc
.tdesc
.vt
== VT_VOID
, "got %d\n", pfuncdesc
->elemdescFunc
.tdesc
.vt
);
1780 ok(pfuncdesc
->wFuncFlags
== 0, "got 0x%x\n", pfuncdesc
->wFuncFlags
);
1782 edesc
= pfuncdesc
->lprgelemdescParam
;
1783 ok(edesc
->tdesc
.vt
== VT_INT
, "got: %d\n", edesc
->tdesc
.vt
);
1784 ok(U(*edesc
).paramdesc
.wParamFlags
== PARAMFLAG_FHASDEFAULT
, "got: 0x%x\n", U(*edesc
).paramdesc
.wParamFlags
);
1785 ok(U(*edesc
).paramdesc
.pparamdescex
!= NULL
, "got: %p\n", U(*edesc
).paramdesc
.pparamdescex
);
1786 ok(U(*edesc
).paramdesc
.pparamdescex
->cBytes
== sizeof(PARAMDESCEX
), "got: %d\n",
1787 U(*edesc
).paramdesc
.pparamdescex
->cBytes
);
1788 ok(V_VT(&U(*edesc
).paramdesc
.pparamdescex
->varDefaultValue
) == VT_I4
, "got: %d\n",
1789 V_VT(&U(*edesc
).paramdesc
.pparamdescex
->varDefaultValue
));
1790 ok(V_I4(&U(*edesc
).paramdesc
.pparamdescex
->varDefaultValue
) == 0x123, "got: 0x%x\n",
1791 V_I4(&U(*edesc
).paramdesc
.pparamdescex
->varDefaultValue
));
1793 ITypeInfo2_ReleaseFuncDesc(ti2
, pfuncdesc
);
1795 U(elemdesc
[0]).idldesc
.dwReserved
= 0;
1796 U(elemdesc
[0]).idldesc
.wIDLFlags
= IDLFLAG_FIN
;
1797 elemdesc
[1].tdesc
.vt
= VT_UI2
;
1798 U(elemdesc
[1]).paramdesc
.wParamFlags
= PARAMFLAG_FHASDEFAULT
;
1799 U(elemdesc
[1]).paramdesc
.pparamdescex
= ¶mdescex
;
1800 V_VT(¶mdescex
.varDefaultValue
) = VT_UI2
;
1801 V_UI2(¶mdescex
.varDefaultValue
) = 0xffff;
1802 funcdesc
.cParams
= 2;
1803 hres
= ICreateTypeInfo_AddFuncDesc(createti
, 3, &funcdesc
);
1804 ok(hres
== S_OK
, "got %08x\n", hres
);
1806 hres
= ITypeInfo2_GetFuncDesc(ti2
, 3, &pfuncdesc
);
1807 ok(hres
== S_OK
, "got %08x\n", hres
);
1809 ok(pfuncdesc
->memid
== 0x60010009, "got %x\n", pfuncdesc
->memid
);
1810 ok(pfuncdesc
->lprgscode
== NULL
, "got %p\n", pfuncdesc
->lprgscode
);
1811 ok(pfuncdesc
->lprgelemdescParam
!= NULL
, "got %p\n", pfuncdesc
->lprgelemdescParam
);
1812 ok(pfuncdesc
->funckind
== FUNC_PUREVIRTUAL
, "got 0x%x\n", pfuncdesc
->funckind
);
1813 ok(pfuncdesc
->invkind
== INVOKE_FUNC
, "got 0x%x\n", pfuncdesc
->invkind
);
1814 ok(pfuncdesc
->callconv
== CC_STDCALL
, "got 0x%x\n", pfuncdesc
->callconv
);
1815 ok(pfuncdesc
->cParams
== 2, "got %d\n", pfuncdesc
->cParams
);
1816 ok(pfuncdesc
->cParamsOpt
== 0, "got %d\n", pfuncdesc
->cParamsOpt
);
1817 todo_wine
ok(pfuncdesc
->oVft
== 24 ||
1818 broken(pfuncdesc
->oVft
== 36) /* xp64 */,
1819 "got %d\n", pfuncdesc
->oVft
);
1820 ok(pfuncdesc
->cScodes
== 0, "got %d\n", pfuncdesc
->cScodes
);
1821 ok(pfuncdesc
->elemdescFunc
.tdesc
.vt
== VT_VOID
, "got %d\n", pfuncdesc
->elemdescFunc
.tdesc
.vt
);
1822 ok(pfuncdesc
->wFuncFlags
== 0, "got 0x%x\n", pfuncdesc
->wFuncFlags
);
1824 edesc
= pfuncdesc
->lprgelemdescParam
;
1825 ok(edesc
->tdesc
.vt
== VT_INT
, "got: %d\n", edesc
->tdesc
.vt
);
1826 ok(U(*edesc
).paramdesc
.wParamFlags
== PARAMFLAG_FIN
, "got: 0x%x\n", U(*edesc
).paramdesc
.wParamFlags
);
1827 ok(U(*edesc
).paramdesc
.pparamdescex
== NULL
, "got: %p\n", U(*edesc
).paramdesc
.pparamdescex
);
1829 edesc
= pfuncdesc
->lprgelemdescParam
+ 1;
1830 ok(edesc
->tdesc
.vt
== VT_UI2
, "got: %d\n", edesc
->tdesc
.vt
);
1831 ok(U(*edesc
).paramdesc
.wParamFlags
== PARAMFLAG_FHASDEFAULT
, "got: 0x%x\n", U(*edesc
).paramdesc
.wParamFlags
);
1832 ok(U(*edesc
).paramdesc
.pparamdescex
!= NULL
, "got: %p\n", U(*edesc
).paramdesc
.pparamdescex
);
1833 ok(U(*edesc
).paramdesc
.pparamdescex
->cBytes
== sizeof(PARAMDESCEX
), "got: %d\n",
1834 U(*edesc
).paramdesc
.pparamdescex
->cBytes
);
1835 ok(V_VT(&U(*edesc
).paramdesc
.pparamdescex
->varDefaultValue
) == VT_UI2
, "got: %d\n",
1836 V_VT(&U(*edesc
).paramdesc
.pparamdescex
->varDefaultValue
));
1837 ok(V_UI2(&U(*edesc
).paramdesc
.pparamdescex
->varDefaultValue
) == 0xFFFF, "got: 0x%x\n",
1838 V_UI2(&U(*edesc
).paramdesc
.pparamdescex
->varDefaultValue
));
1840 ITypeInfo2_ReleaseFuncDesc(ti2
, pfuncdesc
);
1842 U(elemdesc
[0]).paramdesc
.wParamFlags
= PARAMFLAG_FHASDEFAULT
;
1843 U(elemdesc
[0]).paramdesc
.pparamdescex
= ¶mdescex
;
1844 elemdesc
[1].tdesc
.vt
= VT_INT
;
1845 V_VT(¶mdescex
.varDefaultValue
) = VT_INT
;
1846 V_INT(¶mdescex
.varDefaultValue
) = 0xffffffff;
1847 hres
= ICreateTypeInfo_AddFuncDesc(createti
, 3, &funcdesc
);
1848 ok(hres
== S_OK
, "got %08x\n", hres
);
1850 elemdesc
[0].tdesc
.vt
= VT_BSTR
;
1851 elemdesc
[1].tdesc
.vt
= VT_BSTR
;
1852 V_VT(¶mdescex
.varDefaultValue
) = VT_BSTR
;
1853 V_BSTR(¶mdescex
.varDefaultValue
) = SysAllocString(defaultW
);
1854 hres
= ICreateTypeInfo_AddFuncDesc(createti
, 3, &funcdesc
);
1855 ok(hres
== S_OK
, "got %08x\n", hres
);
1856 SysFreeString(V_BSTR(¶mdescex
.varDefaultValue
));
1858 hres
= ITypeInfo2_GetFuncDesc(ti2
, 3, &pfuncdesc
);
1859 ok(hres
== S_OK
, "got %08x\n", hres
);
1861 ok(pfuncdesc
->memid
== 0x6001000b, "got %x\n", pfuncdesc
->memid
);
1862 ok(pfuncdesc
->lprgscode
== NULL
, "got %p\n", pfuncdesc
->lprgscode
);
1863 ok(pfuncdesc
->lprgelemdescParam
!= NULL
, "got %p\n", pfuncdesc
->lprgelemdescParam
);
1864 ok(pfuncdesc
->funckind
== FUNC_PUREVIRTUAL
, "got 0x%x\n", pfuncdesc
->funckind
);
1865 ok(pfuncdesc
->invkind
== INVOKE_FUNC
, "got 0x%x\n", pfuncdesc
->invkind
);
1866 ok(pfuncdesc
->callconv
== CC_STDCALL
, "got 0x%x\n", pfuncdesc
->callconv
);
1867 ok(pfuncdesc
->cParams
== 2, "got %d\n", pfuncdesc
->cParams
);
1868 ok(pfuncdesc
->cParamsOpt
== 0, "got %d\n", pfuncdesc
->cParamsOpt
);
1869 todo_wine
ok(pfuncdesc
->oVft
== 24 ||
1870 broken(pfuncdesc
->oVft
== 36) /* xp64 */,
1871 "got %d\n", pfuncdesc
->oVft
);
1872 ok(pfuncdesc
->cScodes
== 0, "got %d\n", pfuncdesc
->cScodes
);
1873 ok(pfuncdesc
->elemdescFunc
.tdesc
.vt
== VT_VOID
, "got %d\n", pfuncdesc
->elemdescFunc
.tdesc
.vt
);
1874 ok(pfuncdesc
->wFuncFlags
== 0, "got 0x%x\n", pfuncdesc
->wFuncFlags
);
1876 edesc
= pfuncdesc
->lprgelemdescParam
;
1877 ok(edesc
->tdesc
.vt
== VT_BSTR
, "got: %d\n", edesc
->tdesc
.vt
);
1878 ok(U(*edesc
).paramdesc
.wParamFlags
== PARAMFLAG_FHASDEFAULT
, "got: 0x%x\n", U(*edesc
).paramdesc
.wParamFlags
);
1879 ok(U(*edesc
).paramdesc
.pparamdescex
!= NULL
, "got: %p\n", U(*edesc
).paramdesc
.pparamdescex
);
1880 ok(U(*edesc
).paramdesc
.pparamdescex
->cBytes
== sizeof(PARAMDESCEX
), "got: %d\n",
1881 U(*edesc
).paramdesc
.pparamdescex
->cBytes
);
1882 ok(V_VT(&U(*edesc
).paramdesc
.pparamdescex
->varDefaultValue
) == VT_BSTR
, "got: %d\n",
1883 V_VT(&U(*edesc
).paramdesc
.pparamdescex
->varDefaultValue
));
1884 ok(!lstrcmpW(V_BSTR(&U(*edesc
).paramdesc
.pparamdescex
->varDefaultValue
), defaultQW
),
1886 wine_dbgstr_w(V_BSTR(&U(*edesc
).paramdesc
.pparamdescex
->varDefaultValue
)));
1888 edesc
= pfuncdesc
->lprgelemdescParam
+ 1;
1889 ok(edesc
->tdesc
.vt
== VT_BSTR
, "got: %d\n", edesc
->tdesc
.vt
);
1890 ok(U(*edesc
).paramdesc
.wParamFlags
== PARAMFLAG_FHASDEFAULT
, "got: 0x%x\n", U(*edesc
).paramdesc
.wParamFlags
);
1891 ok(U(*edesc
).paramdesc
.pparamdescex
!= NULL
, "got: %p\n", U(*edesc
).paramdesc
.pparamdescex
);
1892 ok(U(*edesc
).paramdesc
.pparamdescex
->cBytes
== sizeof(PARAMDESCEX
), "got: %d\n",
1893 U(*edesc
).paramdesc
.pparamdescex
->cBytes
);
1894 ok(V_VT(&U(*edesc
).paramdesc
.pparamdescex
->varDefaultValue
) == VT_BSTR
, "got: %d\n",
1895 V_VT(&U(*edesc
).paramdesc
.pparamdescex
->varDefaultValue
));
1896 ok(!lstrcmpW(V_BSTR(&U(*edesc
).paramdesc
.pparamdescex
->varDefaultValue
), defaultQW
),
1898 wine_dbgstr_w(V_BSTR(&U(*edesc
).paramdesc
.pparamdescex
->varDefaultValue
)));
1900 ITypeInfo2_ReleaseFuncDesc(ti2
, pfuncdesc
);
1902 elemdesc
[0].tdesc
.vt
= VT_USERDEFINED
;
1903 U(elemdesc
[0].tdesc
).hreftype
= hreftype
;
1904 U(elemdesc
[0]).paramdesc
.pparamdescex
= NULL
;
1905 U(elemdesc
[0]).paramdesc
.wParamFlags
= 0;
1907 funcdesc
.lprgelemdescParam
= elemdesc
;
1908 funcdesc
.invkind
= INVOKE_FUNC
;
1909 funcdesc
.cParams
= 1;
1910 funcdesc
.elemdescFunc
.tdesc
.vt
= VT_VOID
;
1912 hres
= ICreateTypeInfo_AddFuncDesc(createti
, 5, &funcdesc
);
1913 ok(hres
== S_OK
, "got %08x\n", hres
);
1915 hres
= ITypeInfo2_GetFuncDesc(ti2
, 5, &pfuncdesc
);
1916 ok(hres
== S_OK
, "got %08x\n", hres
);
1918 ok(pfuncdesc
->memid
== 0x60010005, "got %x\n", pfuncdesc
->memid
);
1919 ok(pfuncdesc
->lprgscode
== NULL
, "got %p\n", pfuncdesc
->lprgscode
);
1920 ok(pfuncdesc
->lprgelemdescParam
!= NULL
, "got %p\n", pfuncdesc
->lprgelemdescParam
);
1921 ok(pfuncdesc
->funckind
== FUNC_PUREVIRTUAL
, "got 0x%x\n", pfuncdesc
->funckind
);
1922 ok(pfuncdesc
->invkind
== INVOKE_FUNC
, "got 0x%x\n", pfuncdesc
->invkind
);
1923 ok(pfuncdesc
->callconv
== CC_STDCALL
, "got 0x%x\n", pfuncdesc
->callconv
);
1924 ok(pfuncdesc
->cParams
== 1, "got %d\n", pfuncdesc
->cParams
);
1925 ok(pfuncdesc
->cParamsOpt
== 0, "got %d\n", pfuncdesc
->cParamsOpt
);
1926 todo_wine
ok(pfuncdesc
->oVft
== 32 ||
1927 broken(pfuncdesc
->oVft
== 44), /* xp64 */
1928 "got %d\n", pfuncdesc
->oVft
);
1929 ok(pfuncdesc
->cScodes
== 0, "got %d\n", pfuncdesc
->cScodes
);
1930 ok(pfuncdesc
->elemdescFunc
.tdesc
.vt
== VT_VOID
, "got %d\n", pfuncdesc
->elemdescFunc
.tdesc
.vt
);
1931 ok(pfuncdesc
->wFuncFlags
== 0, "got 0x%x\n", pfuncdesc
->wFuncFlags
);
1933 edesc
= pfuncdesc
->lprgelemdescParam
;
1934 ok(U(*edesc
).paramdesc
.pparamdescex
== NULL
, "got: %p\n", U(*edesc
).paramdesc
.pparamdescex
);
1935 ok(U(*edesc
).paramdesc
.wParamFlags
== 0, "got: 0x%x\n", U(*edesc
).paramdesc
.wParamFlags
);
1936 ok(edesc
->tdesc
.vt
== VT_USERDEFINED
, "got: %d\n", edesc
->tdesc
.vt
);
1937 ok(U(edesc
->tdesc
).hreftype
== hreftype
, "got: 0x%x\n", U(edesc
->tdesc
).hreftype
);
1939 ITypeInfo2_ReleaseFuncDesc(ti2
, pfuncdesc
);
1941 hres
= ITypeInfo_GetDocumentation(interface1
, 0, &name
, &docstring
, &helpcontext
, &helpfile
);
1942 ok(hres
== S_OK
, "got %08x\n", hres
);
1943 ok(name
== NULL
, "name != NULL\n");
1944 ok(docstring
== NULL
, "docstring != NULL\n");
1945 ok(helpcontext
== 0x201, "helpcontext != 0x201\n");
1946 ok(!memcmp(helpfile
, helpfileW
, sizeof(helpfileW
)), "helpfile = %s\n", wine_dbgstr_w(helpfile
));
1948 SysFreeString(helpfile
);
1950 hres
= ICreateTypeInfo_SetFuncAndParamNames(createti
, 1000, NULL
, 1);
1951 ok(hres
== E_INVALIDARG
, "got %08x\n", hres
);
1953 hres
= ICreateTypeInfo_SetFuncAndParamNames(createti
, 1000, names1
, 1);
1954 ok(hres
== TYPE_E_ELEMENTNOTFOUND
, "got %08x\n", hres
);
1956 hres
= ICreateTypeInfo_SetFuncAndParamNames(createti
, 0, names1
, 2);
1957 ok(hres
== TYPE_E_ELEMENTNOTFOUND
, "got %08x\n", hres
);
1959 hres
= ICreateTypeInfo_SetFuncAndParamNames(createti
, 0, names2
, 1);
1960 ok(hres
== S_OK
, "got %08x\n", hres
);
1962 hres
= ICreateTypeInfo_SetFuncAndParamNames(createti
, 0, names1
, 1);
1963 ok(hres
== S_OK
, "got %08x\n", hres
);
1965 hres
= ITypeInfo_GetDocumentation(interface1
, 0, &name
, NULL
, NULL
, NULL
);
1966 ok(hres
== S_OK
, "got %08x\n", hres
);
1967 ok(!memcmp(name
, func1W
, sizeof(func1W
)), "name = %s\n", wine_dbgstr_w(name
));
1969 SysFreeString(name
);
1971 hres
= ICreateTypeInfo_SetFuncAndParamNames(createti
, 3, names2
, 3);
1972 ok(hres
== S_OK
, "got %08x\n", hres
);
1974 hres
= ICreateTypeInfo_SetFuncAndParamNames(createti
, 3, names1
, 3);
1975 ok(hres
== TYPE_E_AMBIGUOUSNAME
, "got %08x\n", hres
);
1977 ITypeInfo2_Release(ti2
);
1978 ICreateTypeInfo_Release(createti
);
1980 hres
= ICreateTypeLib_CreateTypeInfo(createtl
, interface1W
, TKIND_INTERFACE
, &createti
);
1981 ok(hres
== TYPE_E_NAMECONFLICT
, "got %08x\n", hres
);
1983 hres
= ICreateTypeLib_CreateTypeInfo(createtl
, interface2W
, TKIND_INTERFACE
, &createti
);
1984 ok(hres
== S_OK
, "got %08x\n", hres
);
1986 hres
= ICreateTypeInfo_QueryInterface(createti
, &IID_ITypeInfo
, (void**)&interface2
);
1987 ok(hres
== S_OK
, "got %08x\n", hres
);
1989 hres
= ITypeInfo_GetRefTypeOfImplType(interface2
, 0, &hreftype
);
1990 ok(hres
== TYPE_E_ELEMENTNOTFOUND
, "got %08x\n", hres
);
1992 hres
= ICreateTypeInfo_AddRefTypeInfo(createti
, interface1
, &hreftype
);
1993 ok(hres
== S_OK
, "got %08x\n", hres
);
1995 hres
= ITypeInfo_GetRefTypeInfo(interface2
, 0, &ti
);
1996 ok(hres
== S_OK
, "got %08x\n", hres
);
1997 ok(ti
== interface1
, "Received and added interfaces are different\n");
1999 ITypeInfo_Release(ti
);
2001 hres
= ICreateTypeInfo_AddImplType(createti
, 0, hreftype
);
2002 ok(hres
== S_OK
, "got %08x\n", hres
);
2004 hres
= ITypeInfo_GetRefTypeOfImplType(interface2
, 0, &hreftype
);
2005 ok(hres
== S_OK
, "got %08x\n", hres
);
2006 ok(hreftype
== 2, "hreftype = %d\n", hreftype
);
2008 hres
= ITypeInfo_GetRefTypeOfImplType(interface2
, -1, &hreftype
);
2009 ok(hres
== TYPE_E_ELEMENTNOTFOUND
, "got %08x\n", hres
);
2011 hres
= ICreateTypeInfo_SetImplTypeFlags(createti
, 0, IMPLTYPEFLAG_FDEFAULT
);
2012 ok(hres
== TYPE_E_BADMODULEKIND
, "got %08x\n", hres
);
2014 hres
= ITypeInfo_GetImplTypeFlags(interface2
, 0, &impltypeflags
);
2015 ok(hres
== S_OK
, "got %08x\n", hres
);
2016 ok(impltypeflags
== 0, "impltypeflags = %x\n", impltypeflags
);
2018 hres
= ITypeInfo_GetImplTypeFlags(interface2
, 1, &impltypeflags
);
2019 ok(hres
== TYPE_E_ELEMENTNOTFOUND
, "got %08x\n", hres
);
2021 funcdesc
.oVft
= 0xaaac;
2022 hres
= ICreateTypeInfo_AddFuncDesc(createti
, 0, &funcdesc
);
2023 ok(hres
== S_OK
, "got %08x\n", hres
);
2024 funcdesc
.oVft
= 0xaaa8;
2025 hres
= ICreateTypeInfo_AddFuncDesc(createti
, 0, &funcdesc
);
2026 ok(hres
== S_OK
, "got %08x\n", hres
);
2029 ICreateTypeInfo_Release(createti
);
2031 VariantInit(&cust_data
);
2033 hres
= ICreateTypeLib_CreateTypeInfo(createtl
, interface3W
, TKIND_INTERFACE
, &createti
);
2034 ok(hres
== S_OK
, "got %08x\n", hres
);
2036 hres
= ICreateTypeInfo_QueryInterface(createti
, &IID_ICreateTypeInfo2
, (void**)&createti2
);
2037 ok(hres
== S_OK
, "got %08x\n", hres
);
2039 hres
= ICreateTypeInfo2_QueryInterface(createti2
, &IID_ITypeInfo2
, (void**)&ti2
);
2040 ok(hres
== S_OK
, "got %08x\n", hres
);
2042 hres
= ITypeInfo2_GetCustData(ti2
, NULL
, NULL
);
2043 ok(hres
== E_INVALIDARG
, "got %08x\n", hres
);
2045 hres
= ITypeInfo2_GetCustData(ti2
, &custguid
, NULL
);
2046 ok(hres
== E_INVALIDARG
, "got %08x\n", hres
);
2048 hres
= ITypeInfo2_GetCustData(ti2
, &custguid
, &cust_data
);
2049 ok(hres
== S_OK
, "got %08x\n", hres
);
2051 hres
= ICreateTypeInfo2_SetCustData(createti2
, NULL
, NULL
);
2052 ok(hres
== E_INVALIDARG
, "got %08x\n", hres
);
2054 hres
= ICreateTypeInfo2_SetCustData(createti2
, &custguid
, NULL
);
2055 ok(hres
== E_INVALIDARG
, "got %08x\n", hres
);
2057 hres
= ICreateTypeInfo2_SetCustData(createti2
, &custguid
, &cust_data
);
2058 ok(hres
== DISP_E_BADVARTYPE
, "got %08x\n", hres
);
2060 V_VT(&cust_data
) = VT_UI4
;
2061 V_I4(&cust_data
) = 0xdeadbeef;
2063 hres
= ICreateTypeInfo2_SetCustData(createti2
, &custguid
, &cust_data
);
2064 ok(hres
== S_OK
, "got %08x\n", hres
);
2066 V_I4(&cust_data
) = 0;
2067 V_VT(&cust_data
) = VT_EMPTY
;
2069 hres
= ITypeInfo2_GetCustData(ti2
, &custguid
, &cust_data
);
2070 ok(hres
== S_OK
, "got %08x\n", hres
);
2072 ok(V_VT(&cust_data
) == VT_UI4
, "got %d\n", V_VT(&cust_data
));
2073 ok(V_I4(&cust_data
) == 0xdeadbeef, "got 0x%08x\n", V_I4(&cust_data
));
2075 V_VT(&cust_data
) = VT_UI4
;
2076 V_I4(&cust_data
) = 12345678;
2078 hres
= ICreateTypeInfo2_SetCustData(createti2
, &custguid
, &cust_data
);
2079 ok(hres
== S_OK
, "got %08x\n", hres
);
2081 V_I4(&cust_data
) = 0;
2082 V_VT(&cust_data
) = VT_EMPTY
;
2084 hres
= ITypeInfo2_GetCustData(ti2
, &custguid
, &cust_data
);
2085 ok(hres
== S_OK
, "got %08x\n", hres
);
2087 ok(V_VT(&cust_data
) == VT_UI4
, "got %d\n", V_VT(&cust_data
));
2088 ok(V_I4(&cust_data
) == 12345678, "got 0x%08x\n", V_I4(&cust_data
));
2090 V_VT(&cust_data
) = VT_BSTR
;
2091 V_BSTR(&cust_data
) = SysAllocString(asdfW
);
2093 hres
= ICreateTypeInfo2_SetCustData(createti2
, &custguid
, &cust_data
);
2094 ok(hres
== S_OK
, "got %08x\n", hres
);
2096 SysFreeString(V_BSTR(&cust_data
));
2097 V_I4(&cust_data
) = 0;
2098 V_VT(&cust_data
) = VT_EMPTY
;
2100 hres
= ITypeInfo2_GetCustData(ti2
, &custguid
, &cust_data
);
2101 ok(hres
== S_OK
, "got %08x\n", hres
);
2103 ok(V_VT(&cust_data
) == VT_BSTR
, "got %d\n", V_VT(&cust_data
));
2104 ok(!lstrcmpW(V_BSTR(&cust_data
), asdfW
), "got %s\n", wine_dbgstr_w(V_BSTR(&cust_data
)));
2105 SysFreeString(V_BSTR(&cust_data
));
2107 V_VT(&cust_data
) = VT_UI4
;
2108 V_UI4(&cust_data
) = 17;
2110 hres
= ITypeInfo2_GetCustData(ti2
, &bogusguid
, &cust_data
);
2111 ok(hres
== S_OK
, "got %08x\n", hres
);
2113 ok(V_VT(&cust_data
) == VT_EMPTY
, "got: %d\n", V_VT(&cust_data
));
2115 ITypeInfo2_Release(ti2
);
2116 ICreateTypeInfo2_Release(createti2
);
2117 ICreateTypeInfo_Release(createti
);
2119 hres
= ICreateTypeLib_CreateTypeInfo(createtl
, coclassW
, TKIND_COCLASS
, &createti
);
2120 ok(hres
== S_OK
, "got %08x\n", hres
);
2122 hres
= ICreateTypeInfo_AddRefTypeInfo(createti
, interface1
, &hreftype
);
2123 ok(hres
== S_OK
, "got %08x\n", hres
);
2125 hres
= ICreateTypeInfo_AddImplType(createti
, 0, hreftype
);
2126 ok(hres
== S_OK
, "got %08x\n", hres
);
2128 hres
= ICreateTypeInfo_AddImplType(createti
, 0, hreftype
);
2129 ok(hres
== TYPE_E_ELEMENTNOTFOUND
, "got %08x\n", hres
);
2131 hres
= ICreateTypeInfo_AddRefTypeInfo(createti
, unknown
, &hreftype
);
2132 ok(hres
== S_OK
, "got %08x\n", hres
);
2134 hres
= ICreateTypeInfo_AddImplType(createti
, 1, hreftype
);
2135 ok(hres
== S_OK
, "got %08x\n", hres
);
2137 hres
= ICreateTypeInfo_AddImplType(createti
, 1, hreftype
);
2138 ok(hres
== TYPE_E_ELEMENTNOTFOUND
, "got %08x\n", hres
);
2140 hres
= ICreateTypeInfo_AddImplType(createti
, 2, hreftype
);
2141 ok(hres
== S_OK
, "got %08x\n", hres
);
2143 hres
= ICreateTypeInfo_SetImplTypeFlags(createti
, 0, IMPLTYPEFLAG_FDEFAULT
);
2144 ok(hres
== S_OK
, "got %08x\n", hres
);
2146 hres
= ICreateTypeInfo_SetImplTypeFlags(createti
, 1, IMPLTYPEFLAG_FRESTRICTED
);
2147 ok(hres
== S_OK
, "got %08x\n", hres
);
2149 hres
= ICreateTypeInfo_QueryInterface(createti
, &IID_ITypeInfo
, (void**)&ti
);
2150 ok(hres
== S_OK
, "got %08x\n", hres
);
2152 hres
= ITypeInfo_GetImplTypeFlags(ti
, 0, NULL
);
2153 ok(hres
== E_INVALIDARG
, "got %08x\n", hres
);
2155 hres
= ITypeInfo_GetImplTypeFlags(ti
, 0, &impltypeflags
);
2156 ok(hres
== S_OK
, "got %08x\n", hres
);
2157 ok(impltypeflags
== IMPLTYPEFLAG_FDEFAULT
, "impltypeflags = %x\n", impltypeflags
);
2159 hres
= ITypeInfo_GetImplTypeFlags(ti
, 1, &impltypeflags
);
2160 ok(hres
== S_OK
, "got %08x\n", hres
);
2161 ok(impltypeflags
== IMPLTYPEFLAG_FRESTRICTED
, "impltypeflags = %x\n", impltypeflags
);
2163 hres
= ITypeInfo_GetImplTypeFlags(ti
, 2, &impltypeflags
);
2164 ok(hres
== S_OK
, "got %08x\n", hres
);
2165 ok(impltypeflags
== 0, "impltypeflags = %x\n", impltypeflags
);
2167 hres
= ITypeInfo_GetRefTypeOfImplType(ti
, 0, &hreftype
);
2168 ok(hres
== S_OK
, "got %08x\n", hres
);
2169 ok(hreftype
== 0, "hreftype = %d\n", hreftype
);
2171 hres
= ITypeInfo_GetRefTypeOfImplType(ti
, 1, &hreftype
);
2172 ok(hres
== S_OK
, "got %08x\n", hres
);
2173 ok(hreftype
== 1, "hreftype = %d\n", hreftype
);
2175 hres
= ITypeInfo_GetRefTypeOfImplType(ti
, 2, &hreftype
);
2176 ok(hres
== S_OK
, "got %08x\n", hres
);
2177 ok(hreftype
== 1, "hreftype = %d\n", hreftype
);
2179 hres
= ITypeInfo_GetRefTypeOfImplType(ti
, -1, &hreftype
);
2180 ok(hres
== TYPE_E_ELEMENTNOTFOUND
, "got %08x\n", hres
);
2182 ITypeInfo_Release(ti
);
2184 ICreateTypeInfo_Release(createti
);
2186 hres
= ICreateTypeLib_CreateTypeInfo(createtl
, dualW
, TKIND_INTERFACE
, &createti
);
2187 ok(hres
== S_OK
, "got %08x\n", hres
);
2189 hres
= ICreateTypeInfo_SetTypeFlags(createti
, TYPEFLAG_FDUAL
);
2190 ok(hres
== S_OK
, "got %08x\n", hres
);
2192 hres
= ICreateTypeInfo_AddFuncDesc(createti
, 0, &funcdesc
);
2193 ok(hres
== S_OK
, "got %08x\n", hres
);
2195 hres
= ICreateTypeInfo_AddRefTypeInfo(createti
, dispatch
, &hreftype
);
2196 ok(hres
== S_OK
, "got %08x\n", hres
);
2198 hres
= ICreateTypeInfo_AddImplType(createti
, 0, hreftype
);
2199 ok(hres
== S_OK
, "got %08x\n", hres
);
2201 hres
= ICreateTypeInfo_QueryInterface(createti
, &IID_ITypeInfo
, (void**)&dual
);
2202 ok(hres
== S_OK
, "got %08x\n", hres
);
2204 hres
= ITypeInfo_GetTypeAttr(dual
, &typeattr
);
2205 ok(hres
== S_OK
, "got %08x\n", hres
);
2206 ok(typeattr
->cbSizeInstance
== 4, "cbSizeInstance = %d\n", typeattr
->cbSizeInstance
);
2207 ok(typeattr
->typekind
== 3, "typekind = %d\n", typeattr
->typekind
);
2208 ok(typeattr
->cFuncs
== 1, "cFuncs = %d\n", typeattr
->cFuncs
);
2209 ok(typeattr
->cVars
== 0, "cVars = %d\n", typeattr
->cVars
);
2210 ok(typeattr
->cImplTypes
== 1, "cImplTypes = %d\n", typeattr
->cImplTypes
);
2211 ok(typeattr
->cbSizeVft
== 32 || broken(typeattr
->cbSizeVft
== 7 * sizeof(void *) + 4), /* xp64 */
2212 "cbSizeVft = %d\n", typeattr
->cbSizeVft
);
2213 ok(typeattr
->cbAlignment
== 4, "cbAlignment = %d\n", typeattr
->cbAlignment
);
2214 ok(typeattr
->wTypeFlags
== (TYPEFLAG_FDISPATCHABLE
|TYPEFLAG_FDUAL
), "wTypeFlags = %d\n", typeattr
->wTypeFlags
);
2215 ok(typeattr
->wMajorVerNum
== 0, "wMajorVerNum = %d\n", typeattr
->wMajorVerNum
);
2216 ok(typeattr
->wMinorVerNum
== 0, "wMinorVerNum = %d\n", typeattr
->wMinorVerNum
);
2218 ITypeInfo_ReleaseTypeAttr(dual
, typeattr
);
2220 hres
= ITypeInfo_GetRefTypeOfImplType(dual
, -1, &hreftype
);
2221 ok(hres
== S_OK
, "got %08x\n", hres
);
2222 ok(hreftype
== -2, "got %08x\n", hreftype
);
2224 hres
= ITypeInfo_GetRefTypeInfo(dual
, -2, &ti
);
2225 ok(hres
== S_OK
, "got %08x\n", hres
);
2227 hres
= ITypeInfo_GetTypeAttr(ti
, &typeattr
);
2228 ok(hres
== S_OK
, "got %08x\n", hres
);
2229 ok(typeattr
->cbSizeInstance
== 4, "cbSizeInstance = %d\n", typeattr
->cbSizeInstance
);
2230 ok(typeattr
->typekind
== 4, "typekind = %d\n", typeattr
->typekind
);
2231 ok(typeattr
->cFuncs
== 8, "cFuncs = %d\n", typeattr
->cFuncs
);
2232 ok(typeattr
->cVars
== 0, "cVars = %d\n", typeattr
->cVars
);
2233 ok(typeattr
->cImplTypes
== 1, "cImplTypes = %d\n", typeattr
->cImplTypes
);
2234 ok(typeattr
->cbSizeVft
== 7 * sizeof(void *), "cbSizeVft = %d\n", typeattr
->cbSizeVft
);
2235 ok(typeattr
->cbAlignment
== 4, "cbAlignment = %d\n", typeattr
->cbAlignment
);
2236 ok(typeattr
->wTypeFlags
== (TYPEFLAG_FDISPATCHABLE
|TYPEFLAG_FDUAL
), "wTypeFlags = %d\n", typeattr
->wTypeFlags
);
2237 ok(typeattr
->wMajorVerNum
== 0, "wMajorVerNum = %d\n", typeattr
->wMajorVerNum
);
2238 ok(typeattr
->wMinorVerNum
== 0, "wMinorVerNum = %d\n", typeattr
->wMinorVerNum
);
2240 ITypeInfo_ReleaseTypeAttr(ti
, typeattr
);
2242 ITypeInfo_Release(ti
);
2244 ICreateTypeInfo_Release(createti
);
2246 hres
= ITypeInfo_GetTypeAttr(interface1
, &typeattr
);
2247 ok(hres
== S_OK
, "got %08x\n", hres
);
2248 ok(typeattr
->cbSizeInstance
== 4, "cbSizeInstance = %d\n", typeattr
->cbSizeInstance
);
2249 ok(typeattr
->typekind
== 3, "typekind = %d\n", typeattr
->typekind
);
2250 ok(typeattr
->cFuncs
== 12, "cFuncs = %d\n", typeattr
->cFuncs
);
2251 ok(typeattr
->cVars
== 0, "cVars = %d\n", typeattr
->cVars
);
2252 ok(typeattr
->cImplTypes
== 1, "cImplTypes = %d\n", typeattr
->cImplTypes
);
2253 ok(typeattr
->cbSizeVft
== 60 || broken(typeattr
->cbSizeVft
== 3 * sizeof(void *) + 48), /* xp64 */
2254 "cbSizeVft = %d\n", typeattr
->cbSizeVft
);
2255 ok(typeattr
->cbAlignment
== 4, "cbAlignment = %d\n", typeattr
->cbAlignment
);
2256 ok(typeattr
->wTypeFlags
== 0, "wTypeFlags = %d\n", typeattr
->wTypeFlags
);
2257 ok(typeattr
->wMajorVerNum
== 0, "wMajorVerNum = %d\n", typeattr
->wMajorVerNum
);
2258 ok(typeattr
->wMinorVerNum
== 0, "wMinorVerNum = %d\n", typeattr
->wMinorVerNum
);
2260 ITypeInfo_ReleaseTypeAttr(interface1
, typeattr
);
2262 hres
= ITypeInfo_GetTypeAttr(interface2
, &typeattr
);
2263 ok(hres
== S_OK
, "got %08x\n", hres
);
2264 ok(typeattr
->cbSizeInstance
== 4, "cbSizeInstance = %d\n", typeattr
->cbSizeInstance
);
2265 ok(typeattr
->typekind
== 3, "typekind = %d\n", typeattr
->typekind
);
2266 ok(typeattr
->cFuncs
== 2, "cFuncs = %d\n", typeattr
->cFuncs
);
2267 ok(typeattr
->cVars
== 0, "cVars = %d\n", typeattr
->cVars
);
2268 ok(typeattr
->cImplTypes
== 1, "cImplTypes = %d\n", typeattr
->cImplTypes
);
2269 ok(typeattr
->cbSizeVft
== 43696, "cbSizeVft = %d\n", typeattr
->cbSizeVft
);
2270 ok(typeattr
->cbAlignment
== 4, "cbAlignment = %d\n", typeattr
->cbAlignment
);
2271 ok(typeattr
->wTypeFlags
== 0, "wTypeFlags = %d\n", typeattr
->wTypeFlags
);
2272 ok(typeattr
->wMajorVerNum
== 0, "wMajorVerNum = %d\n", typeattr
->wMajorVerNum
);
2273 ok(typeattr
->wMinorVerNum
== 0, "wMinorVerNum = %d\n", typeattr
->wMinorVerNum
);
2275 ITypeInfo_ReleaseTypeAttr(interface2
, typeattr
);
2277 hres
= ICreateTypeLib2_SaveAllChanges(createtl
);
2278 ok(hres
== S_OK
, "got %08x\n", hres
);
2280 ok(ITypeInfo_Release(interface2
)==0, "Object should be freed\n");
2281 ok(ITypeInfo_Release(interface1
)==0, "Object should be freed\n");
2282 ok(ITypeInfo_Release(dual
)==0, "Object should be freed\n");
2283 ok(ICreateTypeLib2_Release(createtl
)==0, "Object should be freed\n");
2285 ok(ITypeInfo_Release(dispatch
)==0, "Object should be freed\n");
2286 ok(ITypeInfo_Release(unknown
)==0, "Object should be freed\n");
2287 ok(ITypeLib_Release(stdole
)==0, "Object should be freed\n");
2289 hres
= LoadTypeLibEx(filenameW
, REGKIND_NONE
, &tl
);
2290 ok(hres
== S_OK
, "got %08x\n", hres
);
2291 ok(ITypeLib_Release(tl
)==0, "Object should be freed\n");
2293 DeleteFileA(filename
);
2296 #if 0 /* use this to generate more tests */
2298 #define OLE_CHECK(x) { HRESULT hr = x; if (FAILED(hr)) { printf(#x "failed - %x\n", hr); return; } }
2300 static char *dump_string(LPWSTR wstr
)
2302 int size
= lstrlenW(wstr
)+3;
2303 char *out
= CoTaskMemAlloc(size
);
2304 WideCharToMultiByte(20127, 0, wstr
, -1, out
+1, size
, NULL
, NULL
);
2316 #define MAP_ENTRY(x) { x, #x }
2317 static const struct map_entry tkind_map
[] = {
2318 MAP_ENTRY(TKIND_ENUM
),
2319 MAP_ENTRY(TKIND_RECORD
),
2320 MAP_ENTRY(TKIND_MODULE
),
2321 MAP_ENTRY(TKIND_INTERFACE
),
2322 MAP_ENTRY(TKIND_DISPATCH
),
2323 MAP_ENTRY(TKIND_COCLASS
),
2324 MAP_ENTRY(TKIND_ALIAS
),
2325 MAP_ENTRY(TKIND_UNION
),
2326 MAP_ENTRY(TKIND_MAX
),
2330 static const struct map_entry funckind_map
[] = {
2331 MAP_ENTRY(FUNC_VIRTUAL
),
2332 MAP_ENTRY(FUNC_PUREVIRTUAL
),
2333 MAP_ENTRY(FUNC_NONVIRTUAL
),
2334 MAP_ENTRY(FUNC_STATIC
),
2335 MAP_ENTRY(FUNC_DISPATCH
),
2339 static const struct map_entry invkind_map
[] = {
2340 MAP_ENTRY(INVOKE_FUNC
),
2341 MAP_ENTRY(INVOKE_PROPERTYGET
),
2342 MAP_ENTRY(INVOKE_PROPERTYPUT
),
2343 MAP_ENTRY(INVOKE_PROPERTYPUTREF
),
2349 static const char *map_value(DWORD val
, const struct map_entry
*map
)
2352 static char bufs
[16][256];
2357 if (map
->value
== val
)
2362 buf
= bufs
[(map_id
++)%16];
2363 sprintf(buf
, "0x%x", val
);
2367 static void test_dump_typelib(const char *name
)
2369 WCHAR wszString
[260];
2375 MultiByteToWideChar(CP_ACP
, 0, name
, -1, wszString
, 260);
2376 OLE_CHECK(LoadTypeLib(wszString
, &lib
));
2377 count
= ITypeLib_GetTypeInfoCount(lib
);
2378 printf("/* interfaces count: %d */\n", count
);
2379 for (i
= 0; i
< count
; i
++)
2385 OLE_CHECK(ITypeLib_GetDocumentation(lib
, i
, &name
, NULL
, NULL
, NULL
));
2387 " %s,\n", dump_string(name
));
2388 SysFreeString(name
);
2390 OLE_CHECK(ITypeLib_GetTypeInfo(lib
, i
, &info
));
2391 ITypeInfo_GetTypeAttr(info
, &attr
);
2392 printf(" /*kind*/ %s, /*flags*/ 0x%x, /*align*/ %d, /*size*/ %d,\n"
2393 " /*#vtbl*/ %d, /*#func*/ %d,\n"
2395 map_value(attr
->typekind
, tkind_map
), attr
->wTypeFlags
, attr
->cbAlignment
, attr
->cbSizeInstance
, attr
->cbSizeVft
,
2397 ITypeInfo_ReleaseTypeAttr(info
, attr
);
2405 if (FAILED(ITypeInfo_GetFuncDesc(info
, f
, &desc
)))
2408 " 0x%x, /*func*/ %s, /*inv*/ %s, /*call*/ 0x%x,\n",
2409 desc
->memid
, map_value(desc
->funckind
, funckind_map
), map_value(desc
->invkind
, invkind_map
),
2411 printf(" /*#param*/ %d, /*#opt*/ %d, /*vtbl*/ %d, /*#scodes*/ %d, /*flags*/ 0x%x,\n",
2412 desc
->cParams
, desc
->cParamsOpt
, desc
->oVft
, desc
->cScodes
, desc
->wFuncFlags
);
2413 printf(" {%d, %x}, /* ret */\n", desc
->elemdescFunc
.tdesc
.vt
, desc
->elemdescFunc
.paramdesc
.wParamFlags
);
2414 printf(" { /* params */\n");
2415 for (p
= 0; p
< desc
->cParams
; p
++)
2417 ELEMDESC e
= desc
->lprgelemdescParam
[p
];
2418 printf(" {%d, %x},\n", e
.tdesc
.vt
, e
.paramdesc
.wParamFlags
);
2420 printf(" {-1, -1}\n");
2422 printf(" { /* names */\n");
2423 OLE_CHECK(ITypeInfo_GetNames(info
, desc
->memid
, tab
, 256, &cNames
));
2424 for (p
= 0; p
< cNames
; p
++)
2426 printf(" %s,\n", dump_string(tab
[p
]));
2427 SysFreeString(tab
[p
]);
2432 ITypeInfo_ReleaseFuncDesc(info
, desc
);
2437 ITypeInfo_Release(info
);
2439 ITypeLib_Release(lib
);
2444 typedef struct _element_info
2450 typedef struct _function_info
2461 element_info ret_type
;
2462 element_info params
[15];
2466 typedef struct _interface_info
2472 USHORT cbSizeInstance
;
2475 function_info funcs
[20];
2478 static const interface_info info
[] = {
2479 /* interfaces count: 2 */
2482 /*kind*/ TKIND_DISPATCH
, /*flags*/ 0x1040, /*align*/ 4, /*size*/ 4,
2483 /*#vtbl*/ 7, /*#func*/ 8,
2486 0x60000000, /*func*/ FUNC_DISPATCH
, /*inv*/ INVOKE_FUNC
, /*call*/ 0x4,
2487 /*#param*/ 2, /*#opt*/ 0, /*vtbl*/ 0, /*#scodes*/ 0, /*flags*/ 0x1,
2502 0x60000001, /*func*/ FUNC_DISPATCH
, /*inv*/ INVOKE_FUNC
, /*call*/ 0x4,
2503 /*#param*/ 0, /*#opt*/ 0, /*vtbl*/ 1, /*#scodes*/ 0, /*flags*/ 0x1,
2514 0x60000002, /*func*/ FUNC_DISPATCH
, /*inv*/ INVOKE_FUNC
, /*call*/ 0x4,
2515 /*#param*/ 0, /*#opt*/ 0, /*vtbl*/ 2, /*#scodes*/ 0, /*flags*/ 0x1,
2526 0x60010000, /*func*/ FUNC_DISPATCH
, /*inv*/ INVOKE_FUNC
, /*call*/ 0x4,
2527 /*#param*/ 1, /*#opt*/ 0, /*vtbl*/ 3, /*#scodes*/ 0, /*flags*/ 0x1,
2540 0x60010001, /*func*/ FUNC_DISPATCH
, /*inv*/ INVOKE_FUNC
, /*call*/ 0x4,
2541 /*#param*/ 3, /*#opt*/ 0, /*vtbl*/ 4, /*#scodes*/ 0, /*flags*/ 0x1,
2558 0x60010002, /*func*/ FUNC_DISPATCH
, /*inv*/ INVOKE_FUNC
, /*call*/ 0x4,
2559 /*#param*/ 5, /*#opt*/ 0, /*vtbl*/ 5, /*#scodes*/ 0, /*flags*/ 0x1,
2580 0x60010003, /*func*/ FUNC_DISPATCH
, /*inv*/ INVOKE_FUNC
, /*call*/ 0x4,
2581 /*#param*/ 8, /*#opt*/ 0, /*vtbl*/ 6, /*#scodes*/ 0, /*flags*/ 0x1,
2608 0x60020000, /*func*/ FUNC_DISPATCH
, /*inv*/ INVOKE_FUNC
, /*call*/ 0x4,
2609 /*#param*/ 0, /*#opt*/ 0, /*vtbl*/ 7, /*#scodes*/ 0, /*flags*/ 0x0,
2623 /*kind*/ TKIND_INTERFACE
, /*flags*/ 0x1000, /*align*/ 4, /*size*/ 4,
2624 /*#vtbl*/ 8, /*#func*/ 1,
2627 0x60020000, /*func*/ FUNC_PUREVIRTUAL
, /*inv*/ INVOKE_FUNC
, /*call*/ 0x4,
2628 /*#param*/ 0, /*#opt*/ 0, /*vtbl*/ 7, /*#scodes*/ 0, /*flags*/ 0x0,
2642 #define check_type(elem, info) { \
2643 expect_int((elem)->tdesc.vt, (info)->vt); \
2644 expect_hex(U(*(elem)).paramdesc.wParamFlags, (info)->wParamFlags); \
2647 static void test_dump_typelib(const char *name
)
2649 WCHAR wszName
[MAX_PATH
];
2651 int ifcount
= sizeof(info
)/sizeof(info
[0]);
2654 MultiByteToWideChar(CP_ACP
, 0, name
, -1, wszName
, MAX_PATH
);
2655 ole_check(LoadTypeLibEx(wszName
, REGKIND_NONE
, &typelib
));
2656 expect_eq(ITypeLib_GetTypeInfoCount(typelib
), ifcount
, UINT
, "%d");
2657 for (iface
= 0; iface
< ifcount
; iface
++)
2659 const interface_info
*if_info
= &info
[iface
];
2660 ITypeInfo
*typeinfo
;
2664 trace("Interface %s\n", if_info
->name
);
2665 ole_check(ITypeLib_GetTypeInfo(typelib
, iface
, &typeinfo
));
2666 ole_check(ITypeLib_GetDocumentation(typelib
, iface
, &bstrIfName
, NULL
, NULL
, NULL
));
2667 expect_wstr_acpval(bstrIfName
, if_info
->name
);
2668 SysFreeString(bstrIfName
);
2670 ole_check(ITypeInfo_GetTypeAttr(typeinfo
, &typeattr
));
2671 expect_int(typeattr
->typekind
, if_info
->type
);
2672 expect_hex(typeattr
->wTypeFlags
, if_info
->wTypeFlags
);
2673 expect_int(typeattr
->cbAlignment
, if_info
->cbAlignment
);
2674 expect_int(typeattr
->cbSizeInstance
, if_info
->cbSizeInstance
);
2675 expect_int(typeattr
->cbSizeVft
, if_info
->cbSizeVft
* sizeof(void*));
2676 expect_int(typeattr
->cFuncs
, if_info
->cFuncs
);
2678 for (func
= 0; func
< typeattr
->cFuncs
; func
++)
2680 function_info
*fn_info
= (function_info
*)&if_info
->funcs
[func
];
2686 trace("Function %s\n", fn_info
->names
[0]);
2687 ole_check(ITypeInfo_GetFuncDesc(typeinfo
, func
, &desc
));
2688 expect_int(desc
->memid
, fn_info
->memid
);
2689 expect_int(desc
->funckind
, fn_info
->funckind
);
2690 expect_int(desc
->invkind
, fn_info
->invkind
);
2691 expect_int(desc
->callconv
, fn_info
->callconv
);
2692 expect_int(desc
->cParams
, fn_info
->cParams
);
2693 expect_int(desc
->cParamsOpt
, fn_info
->cParamsOpt
);
2694 ok( desc
->oVft
== fn_info
->vtbl_index
* sizeof(void*) ||
2695 broken(desc
->oVft
== fn_info
->vtbl_index
* 4), /* xp64 */
2696 "desc->oVft got %u\n", desc
->oVft
);
2697 expect_int(desc
->cScodes
, fn_info
->cScodes
);
2698 expect_int(desc
->wFuncFlags
, fn_info
->wFuncFlags
);
2699 ole_check(ITypeInfo_GetNames(typeinfo
, desc
->memid
, namesTab
, 256, &cNames
));
2700 for (i
= 0; i
< cNames
; i
++)
2702 expect_wstr_acpval(namesTab
[i
], fn_info
->names
[i
]);
2703 SysFreeString(namesTab
[i
]);
2705 expect_null(fn_info
->names
[cNames
]);
2707 check_type(&desc
->elemdescFunc
, &fn_info
->ret_type
);
2708 for (i
= 0 ; i
< desc
->cParams
; i
++)
2710 check_type(&desc
->lprgelemdescParam
[i
], &fn_info
->params
[i
]);
2712 expect_int(fn_info
->params
[desc
->cParams
].vt
, (VARTYPE
)-1);
2714 ITypeInfo_ReleaseFuncDesc(typeinfo
, desc
);
2717 ITypeInfo_ReleaseTypeAttr(typeinfo
, typeattr
);
2718 ITypeInfo_Release(typeinfo
);
2720 ITypeLib_Release(typelib
);
2725 static const char *create_test_typelib(int res_no
)
2727 static char filename
[MAX_PATH
];
2733 GetTempFileNameA( ".", "tlb", 0, filename
);
2734 file
= CreateFile( filename
, GENERIC_READ
|GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, 0 );
2735 ok( file
!= INVALID_HANDLE_VALUE
, "file creation failed\n" );
2736 if (file
== INVALID_HANDLE_VALUE
) return NULL
;
2737 res
= FindResource( GetModuleHandle(0), MAKEINTRESOURCE(res_no
), "TYPELIB" );
2738 ok( res
!= 0, "couldn't find resource\n" );
2739 ptr
= LockResource( LoadResource( GetModuleHandle(0), res
));
2740 WriteFile( file
, ptr
, SizeofResource( GetModuleHandle(0), res
), &written
, NULL
);
2741 ok( written
== SizeofResource( GetModuleHandle(0), res
), "couldn't write resource\n" );
2742 CloseHandle( file
);
2746 static void test_create_typelib_lcid(LCID lcid
)
2748 char filename
[MAX_PATH
];
2749 WCHAR name
[MAX_PATH
];
2751 ICreateTypeLib2
*tl
;
2753 DWORD msft_header
[5]; /* five is enough for now */
2756 GetTempFileNameA( ".", "tlb", 0, filename
);
2757 MultiByteToWideChar(CP_ACP
, 0, filename
, -1, name
, MAX_PATH
);
2759 hr
= CreateTypeLib2(SYS_WIN32
, name
, &tl
);
2760 ok(hr
== S_OK
, "got %08x\n", hr
);
2762 hr
= ICreateTypeLib2_SetLcid(tl
, lcid
);
2763 ok(hr
== S_OK
, "got %08x\n", hr
);
2765 hr
= ICreateTypeLib2_SaveAllChanges(tl
);
2766 ok(hr
== S_OK
, "got %08x\n", hr
);
2768 ICreateTypeLib2_Release(tl
);
2770 file
= CreateFileA( filename
, GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, 0, 0 );
2771 ok( file
!= INVALID_HANDLE_VALUE
, "file creation failed\n" );
2773 ReadFile( file
, msft_header
, sizeof(msft_header
), &read
, NULL
);
2774 ok(read
== sizeof(msft_header
), "read %d\n", read
);
2775 CloseHandle( file
);
2777 ok(msft_header
[0] == 0x5446534d, "got %08x\n", msft_header
[0]);
2778 ok(msft_header
[1] == 0x00010002, "got %08x\n", msft_header
[1]);
2779 ok(msft_header
[2] == 0xffffffff, "got %08x\n", msft_header
[2]);
2780 ok(msft_header
[3] == (lcid
? lcid
: 0x409), "got %08x (lcid %08x)\n", msft_header
[3], lcid
);
2781 ok(msft_header
[4] == lcid
, "got %08x (lcid %08x)\n", msft_header
[4], lcid
);
2783 DeleteFileA(filename
);
2786 static void test_create_typelibs(void)
2788 test_create_typelib_lcid(LOCALE_SYSTEM_DEFAULT
);
2789 test_create_typelib_lcid(LOCALE_USER_DEFAULT
);
2790 test_create_typelib_lcid(LOCALE_NEUTRAL
);
2792 test_create_typelib_lcid(0x009);
2793 test_create_typelib_lcid(0x409);
2794 test_create_typelib_lcid(0x809);
2796 test_create_typelib_lcid(0x007);
2797 test_create_typelib_lcid(0x407);
2801 static void test_register_typelib(BOOL system_registration
)
2804 WCHAR filename
[MAX_PATH
];
2805 const char *filenameA
;
2808 char key_name
[MAX_PATH
], uuid
[40];
2809 LONG ret
, expect_ret
;
2818 { TKIND_INTERFACE
, 0 },
2819 { TKIND_INTERFACE
, TYPEFLAG_FDISPATCHABLE
},
2820 { TKIND_INTERFACE
, TYPEFLAG_FOLEAUTOMATION
},
2821 { TKIND_INTERFACE
, TYPEFLAG_FDISPATCHABLE
| TYPEFLAG_FOLEAUTOMATION
},
2822 { TKIND_DISPATCH
, 0 /* TYPEFLAG_FDUAL - widl clears this flag for non-IDispatch derived interfaces */ },
2823 { TKIND_DISPATCH
, 0 /* TYPEFLAG_FDUAL - widl clears this flag for non-IDispatch derived interfaces */ },
2824 { TKIND_DISPATCH
, TYPEFLAG_FDISPATCHABLE
| TYPEFLAG_FDUAL
},
2825 { TKIND_DISPATCH
, TYPEFLAG_FDISPATCHABLE
| TYPEFLAG_FDUAL
},
2826 { TKIND_DISPATCH
, TYPEFLAG_FDISPATCHABLE
},
2827 { TKIND_DISPATCH
, TYPEFLAG_FDISPATCHABLE
},
2828 { TKIND_DISPATCH
, TYPEFLAG_FDISPATCHABLE
}
2831 trace("Starting %s typelib registration tests\n",
2832 system_registration
? "system" : "user");
2834 if (!system_registration
&& (!pRegisterTypeLibForUser
|| !pUnRegisterTypeLibForUser
))
2836 win_skip("User typelib registration functions are not available\n");
2840 filenameA
= create_test_typelib(3);
2841 MultiByteToWideChar(CP_ACP
, 0, filenameA
, -1, filename
, MAX_PATH
);
2843 hr
= LoadTypeLibEx(filename
, REGKIND_NONE
, &typelib
);
2844 ok(hr
== S_OK
, "got %08x\n", hr
);
2846 if (system_registration
)
2847 hr
= RegisterTypeLib(typelib
, filename
, NULL
);
2849 hr
= pRegisterTypeLibForUser(typelib
, filename
, NULL
);
2850 if (hr
== TYPE_E_REGISTRYACCESS
)
2852 win_skip("Insufficient privileges to register typelib in the registry\n");
2853 ITypeLib_Release(typelib
);
2854 DeleteFileA(filenameA
);
2857 ok(hr
== S_OK
, "got %08x\n", hr
);
2859 count
= ITypeLib_GetTypeInfoCount(typelib
);
2860 ok(count
== 11, "got %d\n", count
);
2862 for(i
= 0; i
< count
; i
++)
2864 ITypeInfo
*typeinfo
;
2867 hr
= ITypeLib_GetTypeInfo(typelib
, i
, &typeinfo
);
2868 ok(hr
== S_OK
, "got %08x\n", hr
);
2870 hr
= ITypeInfo_GetTypeAttr(typeinfo
, &attr
);
2871 ok(hr
== S_OK
, "got %08x\n", hr
);
2873 ok(attr
->typekind
== attrs
[i
].kind
, "%d: got kind %d\n", i
, attr
->typekind
);
2874 ok(attr
->wTypeFlags
== attrs
[i
].flags
, "%d: got flags %04x\n", i
, attr
->wTypeFlags
);
2876 if(attr
->typekind
== TKIND_DISPATCH
&& (attr
->wTypeFlags
& TYPEFLAG_FDUAL
))
2879 ITypeInfo
*dual_info
;
2880 TYPEATTR
*dual_attr
;
2882 hr
= ITypeInfo_GetRefTypeOfImplType(typeinfo
, -1, &reftype
);
2883 ok(hr
== S_OK
, "got %08x\n", hr
);
2885 hr
= ITypeInfo_GetRefTypeInfo(typeinfo
, reftype
, &dual_info
);
2886 ok(hr
== S_OK
, "got %08x\n", hr
);
2888 hr
= ITypeInfo_GetTypeAttr(dual_info
, &dual_attr
);
2889 ok(hr
== S_OK
, "got %08x\n", hr
);
2891 ok(dual_attr
->typekind
== TKIND_INTERFACE
, "%d: got kind %d\n", i
, dual_attr
->typekind
);
2892 ok(dual_attr
->wTypeFlags
== (TYPEFLAG_FDISPATCHABLE
| TYPEFLAG_FOLEAUTOMATION
| TYPEFLAG_FDUAL
), "%d: got flags %04x\n", i
, dual_attr
->wTypeFlags
);
2894 ITypeInfo_ReleaseTypeAttr(dual_info
, dual_attr
);
2895 ITypeInfo_Release(dual_info
);
2899 StringFromGUID2(&attr
->guid
, uuidW
, sizeof(uuidW
) / sizeof(uuidW
[0]));
2900 WideCharToMultiByte(CP_ACP
, 0, uuidW
, -1, uuid
, sizeof(uuid
), NULL
, NULL
);
2901 sprintf(key_name
, "Interface\\%s", uuid
);
2903 /* All dispinterfaces will be registered (this includes dual interfaces) as well
2904 as oleautomation interfaces */
2905 if((attr
->typekind
== TKIND_INTERFACE
&& (attr
->wTypeFlags
& TYPEFLAG_FOLEAUTOMATION
)) ||
2906 attr
->typekind
== TKIND_DISPATCH
)
2907 expect_ret
= ERROR_SUCCESS
;
2909 expect_ret
= ERROR_FILE_NOT_FOUND
;
2911 ret
= RegOpenKeyExA(HKEY_CLASSES_ROOT
, key_name
, 0, KEY_READ
, &hkey
);
2912 ok(ret
== expect_ret
, "%d: got %d\n", i
, ret
);
2913 if(ret
== ERROR_SUCCESS
) RegCloseKey(hkey
);
2915 ITypeInfo_ReleaseTypeAttr(typeinfo
, attr
);
2916 ITypeInfo_Release(typeinfo
);
2919 if (system_registration
)
2920 hr
= UnRegisterTypeLib(&LIBID_register_test
, 1, 0, LOCALE_NEUTRAL
, is_win64
? SYS_WIN64
: SYS_WIN32
);
2922 hr
= pUnRegisterTypeLibForUser(&LIBID_register_test
, 1, 0, LOCALE_NEUTRAL
, is_win64
? SYS_WIN64
: SYS_WIN32
);
2923 ok(hr
== S_OK
, "got %08x\n", hr
);
2925 ITypeLib_Release(typelib
);
2926 DeleteFileA( filenameA
);
2929 static void test_LoadTypeLib(void)
2934 static const WCHAR kernel32_dllW
[] = {'k','e','r','n','e','l','3','2','.','d','l','l',0};
2936 hres
= LoadTypeLib(kernel32_dllW
, &tl
);
2937 ok(hres
== TYPE_E_CANTLOADLIBRARY
, "LoadTypeLib returned: %08x, expected TYPE_E_CANTLOADLIBRARY\n", hres
);
2940 static void test_SetVarHelpContext(void)
2942 static OLECHAR nameW
[] = {'n','a','m','e',0};
2943 CHAR filenameA
[MAX_PATH
];
2944 WCHAR filenameW
[MAX_PATH
];
2945 ICreateTypeLib2
*ctl
;
2946 ICreateTypeInfo
*cti
;
2951 GetTempFileNameA(".", "tlb", 0, filenameA
);
2952 MultiByteToWideChar(CP_ACP
, 0, filenameA
, -1, filenameW
, MAX_PATH
);
2954 hr
= CreateTypeLib2(SYS_WIN32
, filenameW
, &ctl
);
2955 ok(hr
== S_OK
, "got %08x\n", hr
);
2957 hr
= ICreateTypeLib2_CreateTypeInfo(ctl
, nameW
, TKIND_ENUM
, &cti
);
2958 ok(hr
== S_OK
, "got %08x\n", hr
);
2960 hr
= ICreateTypeInfo_SetVarHelpContext(cti
, 0, 0);
2961 ok(hr
== TYPE_E_ELEMENTNOTFOUND
, "got %08x\n", hr
);
2963 memset(&desc
, 0, sizeof(desc
));
2964 desc
.elemdescVar
.tdesc
.vt
= VT_INT
;
2965 desc
.varkind
= VAR_CONST
;
2969 U(desc
).lpvarValue
= &v
;
2970 hr
= ICreateTypeInfo2_AddVarDesc(cti
, 0, &desc
);
2971 ok(hr
== S_OK
, "got %08x\n", hr
);
2973 hr
= ICreateTypeInfo2_SetVarHelpContext(cti
, 0, 0);
2974 ok(hr
== S_OK
, "got %08x\n", hr
);
2977 hr
= ICreateTypeInfo2_SetVarHelpContext(cti
, 0, 1);
2978 ok(hr
== S_OK
, "got %08x\n", hr
);
2980 /* wrong index now */
2981 hr
= ICreateTypeInfo2_SetVarHelpContext(cti
, 1, 0);
2982 ok(hr
== TYPE_E_ELEMENTNOTFOUND
, "got %08x\n", hr
);
2984 ICreateTypeInfo_Release(cti
);
2985 ICreateTypeLib2_Release(ctl
);
2986 DeleteFileA(filenameA
);
2989 static void test_SetFuncAndParamNames(void)
2991 static OLECHAR nameW
[] = {'n','a','m','e',0};
2992 static OLECHAR prop
[] = {'p','r','o','p',0};
2993 static OLECHAR
*propW
[] = {prop
};
2994 CHAR filenameA
[MAX_PATH
];
2995 WCHAR filenameW
[MAX_PATH
];
2996 ICreateTypeLib2
*ctl
;
2997 ICreateTypeInfo
*cti
;
3002 GetTempFileNameA(".", "tlb", 0, filenameA
);
3003 MultiByteToWideChar(CP_ACP
, 0, filenameA
, -1, filenameW
, MAX_PATH
);
3005 hr
= CreateTypeLib2(SYS_WIN32
, filenameW
, &ctl
);
3006 ok(hr
== S_OK
, "got %08x\n", hr
);
3008 hr
= ICreateTypeLib2_CreateTypeInfo(ctl
, nameW
, TKIND_DISPATCH
, &cti
);
3009 ok(hr
== S_OK
, "got %08x\n", hr
);
3012 memset(&funcdesc
, 0, sizeof(FUNCDESC
));
3013 funcdesc
.funckind
= FUNC_DISPATCH
;
3014 funcdesc
.callconv
= CC_STDCALL
;
3015 funcdesc
.elemdescFunc
.tdesc
.vt
= VT_VOID
;
3016 funcdesc
.wFuncFlags
= FUNCFLAG_FBINDABLE
;
3019 memset(&edesc
, 0, sizeof(edesc
));
3020 edesc
.tdesc
.vt
= VT_BSTR
;
3021 U(edesc
).idldesc
.dwReserved
= 0;
3022 U(edesc
).idldesc
.wIDLFlags
= IDLFLAG_FIN
;
3024 funcdesc
.lprgelemdescParam
= &edesc
;
3025 funcdesc
.invkind
= INVOKE_PROPERTYPUT
;
3026 funcdesc
.cParams
= 1;
3028 hr
= ICreateTypeInfo_AddFuncDesc(cti
, 0, &funcdesc
);
3029 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3032 hr
= ICreateTypeInfo_SetFuncAndParamNames(cti
, 0, propW
, 1);
3033 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3036 funcdesc
.invkind
= INVOKE_PROPERTYPUTREF
;
3037 hr
= ICreateTypeInfo_AddFuncDesc(cti
, 1, &funcdesc
);
3038 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3041 hr
= ICreateTypeInfo_SetFuncAndParamNames(cti
, 1, propW
, 1);
3042 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3044 funcdesc
.invkind
= INVOKE_PROPERTYGET
;
3045 funcdesc
.cParams
= 0;
3046 hr
= ICreateTypeInfo_AddFuncDesc(cti
, 2, &funcdesc
);
3047 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3050 hr
= ICreateTypeInfo_SetFuncAndParamNames(cti
, 2, propW
, 1);
3051 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3053 ICreateTypeInfo_Release(cti
);
3054 ICreateTypeLib2_Release(ctl
);
3055 DeleteFileA(filenameA
);
3058 static void test_SetVarDocString(void)
3060 static OLECHAR nameW
[] = {'n','a','m','e',0};
3061 static OLECHAR doc1W
[] = {'d','o','c','1',0};
3062 static OLECHAR doc2W
[] = {'d','o','c','2',0};
3063 CHAR filenameA
[MAX_PATH
];
3064 WCHAR filenameW
[MAX_PATH
];
3065 ICreateTypeLib2
*ctl
;
3066 ICreateTypeInfo
*cti
;
3071 GetTempFileNameA(".", "tlb", 0, filenameA
);
3072 MultiByteToWideChar(CP_ACP
, 0, filenameA
, -1, filenameW
, MAX_PATH
);
3074 hr
= CreateTypeLib2(SYS_WIN32
, filenameW
, &ctl
);
3075 ok(hr
== S_OK
, "got %08x\n", hr
);
3077 hr
= ICreateTypeLib2_CreateTypeInfo(ctl
, nameW
, TKIND_ENUM
, &cti
);
3078 ok(hr
== S_OK
, "got %08x\n", hr
);
3080 hr
= ICreateTypeInfo_SetVarDocString(cti
, 0, doc1W
);
3081 ok(hr
== TYPE_E_ELEMENTNOTFOUND
, "got %08x\n", hr
);
3083 hr
= ICreateTypeInfo_SetVarDocString(cti
, 0, NULL
);
3084 ok(hr
== E_INVALIDARG
, "got %08x\n", hr
);
3086 memset(&desc
, 0, sizeof(desc
));
3087 desc
.elemdescVar
.tdesc
.vt
= VT_INT
;
3088 desc
.varkind
= VAR_CONST
;
3092 U(desc
).lpvarValue
= &v
;
3093 hr
= ICreateTypeInfo2_AddVarDesc(cti
, 0, &desc
);
3094 ok(hr
== S_OK
, "got %08x\n", hr
);
3096 hr
= ICreateTypeInfo_SetVarDocString(cti
, 0, NULL
);
3097 ok(hr
== E_INVALIDARG
, "got %08x\n", hr
);
3099 hr
= ICreateTypeInfo_SetVarDocString(cti
, 0, doc1W
);
3100 ok(hr
== S_OK
, "got %08x\n", hr
);
3103 hr
= ICreateTypeInfo_SetVarDocString(cti
, 0, doc2W
);
3104 ok(hr
== S_OK
, "got %08x\n", hr
);
3106 /* wrong index now */
3107 hr
= ICreateTypeInfo2_SetVarDocString(cti
, 1, doc1W
);
3108 ok(hr
== TYPE_E_ELEMENTNOTFOUND
, "got %08x\n", hr
);
3110 ICreateTypeInfo_Release(cti
);
3111 ICreateTypeLib2_Release(ctl
);
3112 DeleteFileA(filenameA
);
3115 static void test_FindName(void)
3117 static const WCHAR invalidW
[] = {'i','n','v','a','l','i','d',0};
3125 hr
= LoadTypeLib(wszStdOle2
, &tl
);
3126 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3128 hr
= ITypeLib_FindName(tl
, NULL
, 0, NULL
, NULL
, NULL
);
3129 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
3131 lstrcpyW(buffW
, wszGUID
);
3132 hr
= ITypeLib_FindName(tl
, buffW
, 0, NULL
, NULL
, NULL
);
3133 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
3136 ti
= (void*)0xdeadbeef;
3137 hr
= ITypeLib_FindName(tl
, buffW
, 0, &ti
, NULL
, &c
);
3138 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
3139 ok(c
== 0, "got %d\n", c
);
3140 ok(ti
== (void*)0xdeadbeef, "got %p\n", ti
);
3143 ti
= (void*)0xdeadbeef;
3144 hr
= ITypeLib_FindName(tl
, buffW
, 0, &ti
, NULL
, &c
);
3145 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
3146 ok(c
== 1, "got %d\n", c
);
3147 ok(ti
== (void*)0xdeadbeef, "got %p\n", ti
);
3151 ti
= (void*)0xdeadbeef;
3152 hr
= ITypeLib_FindName(tl
, buffW
, 0, &ti
, &memid
, &c
);
3153 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3155 ok(memid
== -1, "got %d\n", memid
);
3156 ok(!lstrcmpW(buffW
, wszGUID
), "got %s\n", wine_dbgstr_w(buffW
));
3157 ok(c
== 1, "got %d\n", c
);
3158 ITypeInfo_Release(ti
);
3162 lstrcpyW(buffW
, wszguid
);
3163 ti
= (void*)0xdeadbeef;
3164 hr
= ITypeLib_FindName(tl
, buffW
, 0, &ti
, &memid
, &c
);
3165 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3167 ok(memid
== -1, "got %d\n", memid
);
3168 ok(!lstrcmpW(buffW
, wszGUID
), "got %s\n", wine_dbgstr_w(buffW
));
3169 ok(c
== 1, "got %d\n", c
);
3172 ITypeInfo_Release(ti
);
3176 lstrcpyW(buffW
, invalidW
);
3177 ti
= (void*)0xdeadbeef;
3178 hr
= ITypeLib_FindName(tl
, buffW
, 0, &ti
, &memid
, &c
);
3179 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3180 ok(memid
== -1, "got %d\n", memid
);
3181 ok(!lstrcmpW(buffW
, invalidW
), "got %s\n", wine_dbgstr_w(buffW
));
3182 ok(c
== 0, "got %d\n", c
);
3183 ok(ti
== (void*)0xdeadbeef, "got %p\n", ti
);
3185 ITypeLib_Release(tl
);
3190 const char *filename
;
3192 init_function_pointers();
3194 ref_count_test(wszStdOle2
);
3196 test_CreateDispTypeInfo();
3198 test_DispCallFunc();
3199 test_QueryPathOfRegTypeLib(32);
3200 if(sizeof(void*) == 8)
3201 test_QueryPathOfRegTypeLib(64);
3203 test_CreateTypeLib();
3204 test_SetVarHelpContext();
3205 test_SetFuncAndParamNames();
3206 test_SetVarDocString();
3209 if ((filename
= create_test_typelib(2)))
3211 test_dump_typelib( filename
);
3212 DeleteFile( filename
);
3215 test_register_typelib(TRUE
);
3216 test_register_typelib(FALSE
);
3217 test_create_typelibs();