ReactOS 0.4.16-dev-598-gc07fba4
typelib.c
Go to the documentation of this file.
1/*
2 * ITypeLib and ITypeInfo test
3 *
4 * Copyright 2004 Jacek Caban
5 * Copyright 2006,2015 Dmitry Timoshkov
6 *
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.
11 *
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.
16 *
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
20 */
21
22#define NONAMELESSSTRUCT
23#define NONAMELESSUNION
24
25#define COBJMACROS
26#define CONST_VTABLE
27
28#include <wine/test.h>
29#include <stdarg.h>
30#include <stdio.h>
31#include <assert.h>
32
33#include "windef.h"
34#include "winbase.h"
35#include "objbase.h"
36#include "oleauto.h"
37#include "ocidl.h"
38#include "shlwapi.h"
39#include "tmarshal.h"
40#include "olectl.h"
41
42#include "test_reg.h"
43#include "test_tlb.h"
44
45#define expect_eq(expr, value, type, format) { type _ret = (expr); ok((value) == _ret, #expr " expected " format " got " format "\n", value, _ret); }
46#define expect_int(expr, value) expect_eq(expr, (int)(value), int, "%d")
47#define expect_hex(expr, value) expect_eq(expr, (int)(value), int, "0x%x")
48#define expect_null(expr) expect_eq(expr, NULL, const void *, "%p")
49#define expect_guid(expected, guid) { ok(IsEqualGUID(expected, guid), "got wrong guid %s\n", wine_dbgstr_guid(guid)); }
50
51#define expect_wstr_acpval(expr, value) \
52 { \
53 CHAR buf[260]; \
54 expect_eq(!WideCharToMultiByte(CP_ACP, 0, (expr), -1, buf, 260, NULL, NULL), 0, int, "%d"); \
55 ok(strcmp(value, buf) == 0, #expr " expected \"%s\" got \"%s\"\n", value, buf); \
56 }
57
58#define ole_expect(expr, expect) { \
59 HRESULT r = expr; \
60 ok(r == (expect), #expr " returned %x, expected %s (%x)\n", r, #expect, expect); \
61}
62
63#define ole_check(expr) ole_expect(expr, S_OK);
64
65#define ok_ole_success(hr, func) ok(hr == S_OK, #func " failed with error 0x%08x\n", hr)
66
67#ifdef __i386__
68#define ARCH "x86"
69#elif defined __x86_64__
70#define ARCH "amd64"
71#elif defined __arm__
72#define ARCH "arm"
73#elif defined __aarch64__
74#define ARCH "arm64"
75#else
76#define ARCH "none"
77#endif
78
79static HRESULT (WINAPI *pRegisterTypeLibForUser)(ITypeLib*,OLECHAR*,OLECHAR*);
80static HRESULT (WINAPI *pUnRegisterTypeLibForUser)(REFGUID,WORD,WORD,LCID,SYSKIND);
81
82static BOOL (WINAPI *pActivateActCtx)(HANDLE,ULONG_PTR*);
83static HANDLE (WINAPI *pCreateActCtxW)(PCACTCTXW);
84static BOOL (WINAPI *pDeactivateActCtx)(DWORD,ULONG_PTR);
85static VOID (WINAPI *pReleaseActCtx)(HANDLE);
86static BOOL (WINAPI *pIsWow64Process)(HANDLE,LPBOOL);
87static LONG (WINAPI *pRegDeleteKeyExW)(HKEY,LPCWSTR,REGSAM,DWORD);
88
89static const WCHAR wszStdOle2[] = {'s','t','d','o','l','e','2','.','t','l','b',0};
90static WCHAR wszGUID[] = {'G','U','I','D',0};
91static WCHAR wszguid[] = {'g','u','i','d',0};
92
93static const BOOL is_win64 = sizeof(void *) > sizeof(int);
94
95#ifdef __i386__
96static const BOOL abi_supports_stdcall = TRUE;
97#else
99#endif
100
101static HRESULT WINAPI collection_QueryInterface(ICollection *iface, REFIID riid, void **ret)
102{
105 IsEqualIID(riid, &IID_ICollection))
106 {
107 *ret = iface;
108 return S_OK;
109 }
110
111 return E_NOINTERFACE;
112}
113
114static ULONG WINAPI collection_AddRef(ICollection *iface)
115{
116 return 2;
117}
118
119static ULONG WINAPI collection_Release(ICollection *iface)
120{
121 return 1;
122}
123
125{
126 ok(0, "unexpected call\n");
127 *cnt = 0;
128 return E_NOTIMPL;
129}
130
131static HRESULT WINAPI collection_GetTypeInfo(ICollection *iface, UINT index, LCID lcid, ITypeInfo **ti)
132{
133 ok(0, "unexpected call\n");
134 return E_NOTIMPL;
135}
136
138 UINT cnt, LCID lcid, DISPID *dispid)
139{
140 ok(0, "unexpected call\n");
141 return E_NOTIMPL;
142}
143
144static HRESULT WINAPI collection_Invoke(ICollection *iface, DISPID dispid, REFIID riid,
145 LCID lcid, WORD flags, DISPPARAMS *dispparams, VARIANT *res, EXCEPINFO *ei, UINT *argerr)
146{
147 if(dispid != DISPID_VALUE) {
148 ok(0, "unexpected call\n");
149 return E_NOTIMPL;
150 }
151
152 ok(flags == (DISPATCH_METHOD|DISPATCH_PROPERTYGET), "flags = %x\n", flags);
153 ok(dispparams != NULL, "dispparams == NULL\n");
154 ok(!dispparams->rgdispidNamedArgs, "dispparams->rgdispidNamedArgs != NULL\n");
155 ok(dispparams->cArgs == 1, "dispparams->cArgs = %d\n", dispparams->cArgs);
156 ok(!dispparams->cNamedArgs, "dispparams->cNamedArgs = %d\n", dispparams->cNamedArgs);
157 ok(V_VT(dispparams->rgvarg) == VT_I4, "V_VT(dispparams->rgvarg) = %d\n", V_VT(dispparams->rgvarg));
158 ok(V_I4(dispparams->rgvarg) == 7, "V_I4(dispparams->rgvarg) = %d\n", V_I4(dispparams->rgvarg));
159 ok(res != NULL, "res == NULL\n");
160 ok(V_VT(res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(res));
161
162 V_VT(res) = VT_I4;
163 V_I4(res) = 15;
164 return S_OK;
165}
166
167static HRESULT WINAPI collection_Item(ICollection *iface, int i, int *p)
168{
169 ok(0, "unexpected call\n");
170 return E_NOTIMPL;
171}
172
173static const ICollectionVtbl collectionvtbl = {
182};
183
184static ICollection collection = { &collectionvtbl };
185
186static HRESULT WINAPI invoketest_QueryInterface(IInvokeTest *iface, REFIID riid, void **ret)
187{
190 IsEqualIID(riid, &IID_IInvokeTest))
191 {
192 *ret = iface;
193 return S_OK;
194 }
195
196 return E_NOINTERFACE;
197}
198
199static ULONG WINAPI invoketest_AddRef(IInvokeTest *iface)
200{
201 return 2;
202}
203
204static ULONG WINAPI invoketest_Release(IInvokeTest *iface)
205{
206 return 1;
207}
208
210{
211 ok(0, "unexpected call\n");
212 *cnt = 0;
213 return E_NOTIMPL;
214}
215
216static HRESULT WINAPI invoketest_GetTypeInfo(IInvokeTest *iface, UINT index, LCID lcid, ITypeInfo **ti)
217{
218 ok(0, "unexpected call\n");
219 return E_NOTIMPL;
220}
221
223 UINT cnt, LCID lcid, DISPID *dispid)
224{
225 ok(0, "unexpected call\n");
226 return E_NOTIMPL;
227}
228
229static HRESULT WINAPI invoketest_Invoke(IInvokeTest *iface, DISPID dispid, REFIID riid,
230 LCID lcid, WORD flags, DISPPARAMS *dispparams, VARIANT *res, EXCEPINFO *ei, UINT *argerr)
231{
232 ok(0, "unexpected call\n");
233 return E_NOTIMPL;
234}
235
236static LONG WINAPI invoketest_get_test(IInvokeTest *iface, LONG i)
237{
238 return i+1;
239}
240
241static LONG WINAPI invoketest_putref_testprop(IInvokeTest *iface, LONG *i)
242{
243 return *i+2;
244}
245
247{
248 return 6;
249}
250
251static HRESULT WINAPI invoketest_testfunc(IInvokeTest *iface, int i, int *p)
252{
253 *p = i+1;
254 return S_OK;
255}
256
257static HRESULT WINAPI invoketest_testget(IInvokeTest *iface, ICollection **p)
258{
259 *p = &collection;
260 ICollection_AddRef(&collection);
261 return S_OK;
262}
263
264static const IInvokeTestVtbl invoketestvtbl = {
277};
278
279static IInvokeTest invoketest = { &invoketestvtbl };
280
281static void init_function_pointers(void)
282{
283 HMODULE hmod = GetModuleHandleA("oleaut32.dll");
284 HMODULE hk32 = GetModuleHandleA("kernel32.dll");
285 HMODULE hadv = GetModuleHandleA("advapi32.dll");
286
287 pRegisterTypeLibForUser = (void *)GetProcAddress(hmod, "RegisterTypeLibForUser");
288 pUnRegisterTypeLibForUser = (void *)GetProcAddress(hmod, "UnRegisterTypeLibForUser");
289 pActivateActCtx = (void *)GetProcAddress(hk32, "ActivateActCtx");
290 pCreateActCtxW = (void *)GetProcAddress(hk32, "CreateActCtxW");
291 pDeactivateActCtx = (void *)GetProcAddress(hk32, "DeactivateActCtx");
292 pReleaseActCtx = (void *)GetProcAddress(hk32, "ReleaseActCtx");
293 pIsWow64Process = (void *)GetProcAddress(hk32, "IsWow64Process");
294 pRegDeleteKeyExW = (void*)GetProcAddress(hadv, "RegDeleteKeyExW");
295}
296
297static void ref_count_test(LPCWSTR type_lib)
298{
299 ITypeLib *iface;
300 ITypeInfo *iti1, *iti2;
301 HRESULT hRes;
302 int ref_count;
303
304 trace("Loading type library\n");
305 hRes = LoadTypeLib(type_lib, &iface);
306 ok(hRes == S_OK, "Could not load type library\n");
307 if(hRes != S_OK)
308 return;
309
310 hRes = ITypeLib_GetTypeInfo(iface, 1, &iti1);
311 ok(hRes == S_OK, "ITypeLib_GetTypeInfo failed on index = 1\n");
312 ref_count = ITypeLib_Release(iface);
313 ok(ref_count > 0, "ITypeLib destroyed while ITypeInfo has back pointer\n");
314 if(!ref_count)
315 return;
316
317 hRes = ITypeLib_GetTypeInfo(iface, 1, &iti2);
318 ok(hRes == S_OK, "ITypeLib_GetTypeInfo failed on index = 1\n");
319 ok(iti1 == iti2, "ITypeLib_GetTypeInfo returned different pointers for same indexes\n");
320
321 ITypeLib_AddRef(iface);
322 ITypeInfo_Release(iti2);
323 ITypeInfo_Release(iti1);
324 ok(ITypeLib_Release(iface) == 0, "ITypeLib should be destroyed here.\n");
325}
326
327static void test_TypeComp(void)
328{
329 ITypeComp *pTypeComp, *tcomp, *pTypeComp_tmp;
330 ITypeInfo *pTypeInfo, *ti, *pFontTypeInfo;
331 ITypeLib *pTypeLib;
332 HRESULT hr;
333 ULONG ulHash;
334 DESCKIND desckind;
335 BINDPTR bindptr;
336 static WCHAR wszStdFunctions[] = {'S','t','d','F','u','n','c','t','i','o','n','s',0};
337 static WCHAR wszSavePicture[] = {'S','a','v','e','P','i','c','t','u','r','e',0};
338 static WCHAR wszOLE_TRISTATE[] = {'O','L','E','_','T','R','I','S','T','A','T','E',0};
339 static WCHAR wszUnchecked[] = {'U','n','c','h','e','c','k','e','d',0};
340 static WCHAR wszIUnknown[] = {'I','U','n','k','n','o','w','n',0};
341 static WCHAR wszFont[] = {'F','o','n','t',0};
342 static WCHAR wszStdPicture[] = {'S','t','d','P','i','c','t','u','r','e',0};
343 static WCHAR wszOLE_COLOR[] = {'O','L','E','_','C','O','L','O','R',0};
344 static WCHAR wszClone[] = {'C','l','o','n','e',0};
345 static WCHAR wszclone[] = {'c','l','o','n','e',0};
346 static WCHAR wszJunk[] = {'J','u','n','k',0};
347 static WCHAR wszAddRef[] = {'A','d','d','R','e','f',0};
348
349 hr = LoadTypeLib(wszStdOle2, &pTypeLib);
351
352 hr = ITypeLib_GetTypeComp(pTypeLib, &pTypeComp);
353 ok_ole_success(hr, ITypeLib_GetTypeComp);
354
355 /* test getting a TKIND_MODULE */
356 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszStdFunctions);
357 hr = ITypeComp_Bind(pTypeComp, wszStdFunctions, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
358 ok_ole_success(hr, ITypeComp_Bind);
359
360 ok(desckind == DESCKIND_TYPECOMP,
361 "desckind should have been DESCKIND_TYPECOMP instead of %d\n",
362 desckind);
363 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
364
365 ITypeComp_Release(bindptr.lptcomp);
366
367 /* test getting a TKIND_MODULE with INVOKE_PROPERTYGET */
368 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszStdFunctions);
369 hr = ITypeComp_Bind(pTypeComp, wszStdFunctions, ulHash, INVOKE_PROPERTYGET, &pTypeInfo, &desckind, &bindptr);
370 ok_ole_success(hr, ITypeComp_Bind);
371
372 ok(desckind == DESCKIND_TYPECOMP,
373 "desckind should have been DESCKIND_TYPECOMP instead of %d\n",
374 desckind);
375 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
376 ITypeComp_Release(bindptr.lptcomp);
377
378 /* test getting a function within a TKIND_MODULE */
379 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszSavePicture);
380 hr = ITypeComp_Bind(pTypeComp, wszSavePicture, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
381 ok_ole_success(hr, ITypeComp_Bind);
382
383 ok(desckind == DESCKIND_FUNCDESC,
384 "desckind should have been DESCKIND_FUNCDESC instead of %d\n",
385 desckind);
386 ok(bindptr.lpfuncdesc != NULL, "bindptr.lpfuncdesc should not have been set to NULL\n");
387 ITypeInfo_ReleaseFuncDesc(pTypeInfo, bindptr.lpfuncdesc);
388 ITypeInfo_Release(pTypeInfo);
389
390 /* test getting a function within a TKIND_MODULE with INVOKE_PROPERTYGET */
391 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszSavePicture);
392 hr = ITypeComp_Bind(pTypeComp, wszSavePicture, ulHash, INVOKE_PROPERTYGET, &pTypeInfo, &desckind, &bindptr);
394 "ITypeComp_Bind should have failed with TYPE_E_TYPEMISMATCH instead of 0x%08x\n",
395 hr);
396
397 ok(desckind == DESCKIND_NONE,
398 "desckind should have been DESCKIND_NONE instead of %d\n",
399 desckind);
400 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
401 ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
402
403 /* test getting a TKIND_ENUM */
404 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszOLE_TRISTATE);
405 hr = ITypeComp_Bind(pTypeComp, wszOLE_TRISTATE, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
406 ok_ole_success(hr, ITypeComp_Bind);
407
408 ok(desckind == DESCKIND_TYPECOMP,
409 "desckind should have been DESCKIND_TYPECOMP instead of %d\n",
410 desckind);
411 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
412
413 ITypeComp_Release(bindptr.lptcomp);
414
415 /* test getting a value within a TKIND_ENUM */
416 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszUnchecked);
417 hr = ITypeComp_Bind(pTypeComp, wszUnchecked, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
418 ok_ole_success(hr, ITypeComp_Bind);
419
420 ok(desckind == DESCKIND_VARDESC,
421 "desckind should have been DESCKIND_VARDESC instead of %d\n",
422 desckind);
423 ITypeInfo_ReleaseVarDesc(pTypeInfo, bindptr.lpvardesc);
424 ITypeInfo_Release(pTypeInfo);
425
426 /* test getting a TKIND_INTERFACE */
427 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszIUnknown);
428 hr = ITypeComp_Bind(pTypeComp, wszIUnknown, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
429 ok_ole_success(hr, ITypeComp_Bind);
430
431 ok(desckind == DESCKIND_NONE,
432 "desckind should have been DESCKIND_NONE instead of %d\n",
433 desckind);
434 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
435 ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
436
437 /* test getting a TKIND_DISPATCH */
438 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszFont);
439 hr = ITypeComp_Bind(pTypeComp, wszFont, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
440 ok_ole_success(hr, ITypeComp_Bind);
441
442 ok(desckind == DESCKIND_NONE,
443 "desckind should have been DESCKIND_NONE instead of %d\n",
444 desckind);
445 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
446 ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
447
448 /* test getting a TKIND_RECORD/TKIND_ALIAS */
450 hr = ITypeComp_Bind(pTypeComp, wszGUID, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
451 ok_ole_success(hr, ITypeComp_Bind);
452
453 ok(desckind == DESCKIND_NONE,
454 "desckind should have been DESCKIND_NONE instead of %d\n",
455 desckind);
456 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
457 ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
458
459 /* test getting a TKIND_ALIAS */
460 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszOLE_COLOR);
461 hr = ITypeComp_Bind(pTypeComp, wszOLE_COLOR, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
462 ok_ole_success(hr, ITypeComp_Bind);
463
464 ok(desckind == DESCKIND_NONE,
465 "desckind should have been DESCKIND_NONE instead of %d\n",
466 desckind);
467 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
468 ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
469
470 /* test getting a TKIND_COCLASS */
471 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszStdPicture);
472 hr = ITypeComp_Bind(pTypeComp, wszStdPicture, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
473 ok_ole_success(hr, ITypeComp_Bind);
474
475 ok(desckind == DESCKIND_NONE,
476 "desckind should have been DESCKIND_NONE instead of %d\n",
477 desckind);
478 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
479 ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
480
481 /* test basic BindType argument handling */
483 hr = ITypeComp_BindType(pTypeComp, wszGUID, ulHash, NULL, NULL);
484 ok(hr == E_INVALIDARG, "Got %08x\n", hr);
485
487 pTypeInfo = (void*)0xdeadbeef;
488 hr = ITypeComp_BindType(pTypeComp, wszGUID, ulHash, &pTypeInfo, NULL);
489 ok(hr == E_INVALIDARG, "Got %08x\n", hr);
490 ok(pTypeInfo == (void*)0xdeadbeef, "Got %p\n", pTypeInfo);
491
493 pTypeComp_tmp = (void*)0xdeadbeef;
494 hr = ITypeComp_BindType(pTypeComp, wszGUID, ulHash, NULL, &pTypeComp_tmp);
495 ok(hr == E_INVALIDARG, "Got %08x\n", hr);
496 ok(pTypeComp_tmp == (void*)0xdeadbeef, "Got %p\n", pTypeComp_tmp);
497
499 pTypeComp_tmp = (void*)0xdeadbeef;
500 pTypeInfo = (void*)0xdeadbeef;
501 hr = ITypeComp_BindType(pTypeComp, NULL, ulHash, &pTypeInfo, &pTypeComp_tmp);
502 ok(hr == E_INVALIDARG, "Got %08x\n", hr);
503 ok(pTypeInfo == (void*)0xdeadbeef, "Got %p\n", pTypeInfo);
504 ok(pTypeComp_tmp == (void*)0xdeadbeef, "Got %p\n", pTypeComp_tmp);
505
507 pTypeComp_tmp = (void*)0xdeadbeef;
508 pTypeInfo = (void*)0xdeadbeef;
509 hr = ITypeComp_BindType(pTypeComp, wszGUID, ulHash, &pTypeInfo, &pTypeComp_tmp);
510 ok_ole_success(hr, ITypeComp_BindType);
511 ok(pTypeInfo != NULL, "Got NULL pTypeInfo\n");
512 todo_wine ok(pTypeComp_tmp == NULL, "Got pTypeComp_tmp %p\n", pTypeComp_tmp);
513 ITypeInfo_Release(pTypeInfo);
514 if(pTypeComp_tmp) ITypeComp_Release(pTypeComp_tmp); /* fixme */
515
516 /* test BindType case-insensitivity */
518 pTypeComp_tmp = (void*)0xdeadbeef;
519 pTypeInfo = (void*)0xdeadbeef;
520 hr = ITypeComp_BindType(pTypeComp, wszguid, ulHash, &pTypeInfo, &pTypeComp_tmp);
521 ok_ole_success(hr, ITypeComp_BindType);
522 ok(pTypeInfo != NULL, "Got NULL pTypeInfo\n");
523 todo_wine ok(pTypeComp_tmp == NULL, "Got pTypeComp_tmp %p\n", pTypeComp_tmp);
524 ITypeInfo_Release(pTypeInfo);
525 if(pTypeComp_tmp) ITypeComp_Release(pTypeComp_tmp); /* fixme */
526
527 ITypeComp_Release(pTypeComp);
528
529 /* tests for ITypeComp on an interface */
530 hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, &IID_IFont, &pFontTypeInfo);
531 ok_ole_success(hr, ITypeLib_GetTypeInfoOfGuid);
532
533 hr = ITypeInfo_GetTypeComp(pFontTypeInfo, &pTypeComp);
534 ok_ole_success(hr, ITypeLib_GetTypeComp);
535
536 hr = ITypeInfo_QueryInterface(pFontTypeInfo, &IID_ITypeComp, (void**)&tcomp);
537 ok(hr == S_OK, "got %08x\n", hr);
538 ok(tcomp == pTypeComp, "got %p, was %p\n", tcomp, pTypeComp);
539
540 hr = ITypeComp_QueryInterface(tcomp, &IID_ITypeInfo, (void**)&ti);
541 ok(hr == S_OK, "got %08x\n", hr);
542 ok(ti == pFontTypeInfo, "got %p, was %p\n", ti, pFontTypeInfo);
543 ITypeInfo_Release(ti);
544
545 ITypeComp_Release(tcomp);
546
547 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszClone);
548 hr = ITypeComp_Bind(pTypeComp, wszClone, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
549 ok_ole_success(hr, ITypeComp_Bind);
550
551 ok(desckind == DESCKIND_FUNCDESC,
552 "desckind should have been DESCKIND_FUNCDESC instead of %d\n",
553 desckind);
554 ok(bindptr.lpfuncdesc != NULL, "bindptr.lpfuncdesc should not have been set to NULL\n");
555 ITypeInfo_ReleaseFuncDesc(pTypeInfo, bindptr.lpfuncdesc);
556 ITypeInfo_Release(pTypeInfo);
557
558 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszClone);
559 hr = ITypeComp_Bind(pTypeComp, wszClone, ulHash, INVOKE_PROPERTYGET, &pTypeInfo, &desckind, &bindptr);
560 ok(hr == TYPE_E_TYPEMISMATCH, "ITypeComp_Bind should have failed with TYPE_E_TYPEMISMATCH instead of 0x%08x\n", hr);
561
562 ok(desckind == DESCKIND_NONE,
563 "desckind should have been DESCKIND_NONE instead of %d\n",
564 desckind);
565 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
566 ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
567
568 /* tests that the compare is case-insensitive */
569 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszclone);
570 hr = ITypeComp_Bind(pTypeComp, wszclone, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
571 ok_ole_success(hr, ITypeComp_Bind);
572
573 ok(desckind == DESCKIND_FUNCDESC,
574 "desckind should have been DESCKIND_FUNCDESC instead of %d\n",
575 desckind);
576 ok(bindptr.lpfuncdesc != NULL, "bindptr.lpfuncdesc should not have been set to NULL\n");
577 ITypeInfo_ReleaseFuncDesc(pTypeInfo, bindptr.lpfuncdesc);
578 ITypeInfo_Release(pTypeInfo);
579
580 /* tests nonexistent members */
581 desckind = 0xdeadbeef;
582 bindptr.lptcomp = (ITypeComp*)0xdeadbeef;
583 pTypeInfo = (ITypeInfo*)0xdeadbeef;
584 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszJunk);
585 hr = ITypeComp_Bind(pTypeComp, wszJunk, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
586 ok_ole_success(hr, ITypeComp_Bind);
587 ok(desckind == DESCKIND_NONE, "desckind should have been DESCKIND_NONE, was: %d\n", desckind);
588 ok(pTypeInfo == NULL, "pTypeInfo should have been NULL, was: %p\n", pTypeInfo);
589 ok(bindptr.lptcomp == NULL, "bindptr should have been NULL, was: %p\n", bindptr.lptcomp);
590
591 /* tests inherited members */
592 desckind = 0xdeadbeef;
593 bindptr.lpfuncdesc = NULL;
594 pTypeInfo = NULL;
595 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszAddRef);
596 hr = ITypeComp_Bind(pTypeComp, wszAddRef, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
597 ok_ole_success(hr, ITypeComp_Bind);
598 ok(desckind == DESCKIND_FUNCDESC, "desckind should have been DESCKIND_FUNCDESC, was: %d\n", desckind);
599 ok(pTypeInfo != NULL, "pTypeInfo should not have been NULL, was: %p\n", pTypeInfo);
600 ok(bindptr.lpfuncdesc != NULL, "bindptr should not have been NULL, was: %p\n", bindptr.lpfuncdesc);
601 ITypeInfo_ReleaseFuncDesc(pTypeInfo, bindptr.lpfuncdesc);
602 ITypeInfo_Release(pTypeInfo);
603
604 ITypeComp_Release(pTypeComp);
605 ITypeInfo_Release(pFontTypeInfo);
606 ITypeLib_Release(pTypeLib);
607}
608
609static void test_CreateDispTypeInfo(void)
610{
611 ITypeInfo *pTypeInfo, *pTI2;
612 HRESULT hr;
613 INTERFACEDATA ifdata;
614 METHODDATA methdata[4];
615 PARAMDATA parms1[2];
616 PARAMDATA parms3[1];
617 TYPEATTR *pTypeAttr;
618 HREFTYPE href;
619 FUNCDESC *pFuncDesc;
620 MEMBERID memid;
621
622 static WCHAR func1[] = {'f','u','n','c','1',0};
623 static const WCHAR func2[] = {'f','u','n','c','2',0};
624 static const WCHAR func3[] = {'f','u','n','c','3',0};
625 static const WCHAR parm1[] = {'p','a','r','m','1',0};
626 static const WCHAR parm2[] = {'p','a','r','m','2',0};
627 OLECHAR *name = func1;
628
629 ifdata.pmethdata = methdata;
630 ifdata.cMembers = ARRAY_SIZE(methdata);
631
632 methdata[0].szName = SysAllocString(func1);
633 methdata[0].ppdata = parms1;
634 methdata[0].dispid = 0x123;
635 methdata[0].iMeth = 0;
636 methdata[0].cc = CC_STDCALL;
637 methdata[0].cArgs = 2;
638 methdata[0].wFlags = DISPATCH_METHOD;
639 methdata[0].vtReturn = VT_HRESULT;
640 parms1[0].szName = SysAllocString(parm1);
641 parms1[0].vt = VT_I4;
642 parms1[1].szName = SysAllocString(parm2);
643 parms1[1].vt = VT_BSTR;
644
645 methdata[1].szName = SysAllocString(func2);
646 methdata[1].ppdata = NULL;
647 methdata[1].dispid = 0x124;
648 methdata[1].iMeth = 1;
649 methdata[1].cc = CC_STDCALL;
650 methdata[1].cArgs = 0;
651 methdata[1].wFlags = DISPATCH_PROPERTYGET;
652 methdata[1].vtReturn = VT_I4;
653
654 methdata[2].szName = SysAllocString(func3);
655 methdata[2].ppdata = parms3;
656 methdata[2].dispid = 0x125;
657 methdata[2].iMeth = 3;
658 methdata[2].cc = CC_STDCALL;
659 methdata[2].cArgs = 1;
660 methdata[2].wFlags = DISPATCH_PROPERTYPUT;
661 methdata[2].vtReturn = VT_HRESULT;
662 parms3[0].szName = SysAllocString(parm1);
663 parms3[0].vt = VT_I4;
664
665 methdata[3].szName = SysAllocString(func3);
666 methdata[3].ppdata = NULL;
667 methdata[3].dispid = 0x125;
668 methdata[3].iMeth = 4;
669 methdata[3].cc = CC_STDCALL;
670 methdata[3].cArgs = 0;
671 methdata[3].wFlags = DISPATCH_PROPERTYGET;
672 methdata[3].vtReturn = VT_I4;
673
674 hr = CreateDispTypeInfo(&ifdata, LOCALE_NEUTRAL, &pTypeInfo);
675 ok(hr == S_OK, "hr %08x\n", hr);
676
677 hr = ITypeInfo_GetTypeAttr(pTypeInfo, &pTypeAttr);
678 ok(hr == S_OK, "hr %08x\n", hr);
679
680 ok(pTypeAttr->typekind == TKIND_COCLASS, "typekind %0x\n", pTypeAttr->typekind);
681 ok(pTypeAttr->cImplTypes == 1, "cImplTypes %d\n", pTypeAttr->cImplTypes);
682 ok(pTypeAttr->cFuncs == 0, "cFuncs %d\n", pTypeAttr->cFuncs);
683 ok(pTypeAttr->wTypeFlags == 0, "wTypeFlags %04x\n", pTypeAttr->cFuncs);
684 ITypeInfo_ReleaseTypeAttr(pTypeInfo, pTypeAttr);
685
686 hr = ITypeInfo_GetRefTypeOfImplType(pTypeInfo, 0, &href);
687 ok(hr == S_OK, "hr %08x\n", hr);
688 ok(href == 0, "href = 0x%x\n", href);
689 hr = ITypeInfo_GetRefTypeInfo(pTypeInfo, href, &pTI2);
690 ok(hr == S_OK, "hr %08x\n", hr);
691 hr = ITypeInfo_GetTypeAttr(pTI2, &pTypeAttr);
692 ok(hr == S_OK, "hr %08x\n", hr);
693 ok(pTypeAttr->typekind == TKIND_INTERFACE, "typekind %0x\n", pTypeAttr->typekind);
694 ok(pTypeAttr->cFuncs == 4, "cFuncs %d\n", pTypeAttr->cFuncs);
695 ok(IsEqualGUID(&pTypeAttr->guid, &GUID_NULL), "guid {%08x-...}\n", pTypeAttr->guid.Data1);
696 ok(pTypeAttr->wTypeFlags == 0, "typeflags %08x\n", pTypeAttr->wTypeFlags);
697
698 ITypeInfo_ReleaseTypeAttr(pTI2, pTypeAttr);
699
700 hr = ITypeInfo_GetFuncDesc(pTI2, 0, &pFuncDesc);
701 ok(hr == S_OK, "hr %08x\n", hr);
702 ok(pFuncDesc->memid == 0x123, "memid %x\n", pFuncDesc->memid);
703 ok(pFuncDesc->funckind == FUNC_VIRTUAL, "funckind %d\n", pFuncDesc->funckind);
704 ok(pFuncDesc->invkind == methdata[0].wFlags, "invkind %d\n", pFuncDesc->invkind);
705 ok(pFuncDesc->callconv == methdata[0].cc, "callconv %d\n", pFuncDesc->callconv);
706 ok(pFuncDesc->cParams == methdata[0].cArgs, "cParams %d\n", pFuncDesc->cParams);
707 ok(pFuncDesc->oVft == 0, "oVft %d\n", pFuncDesc->oVft);
708 ok(pFuncDesc->wFuncFlags == 0, "oVft %d\n", pFuncDesc->wFuncFlags);
709 ok(pFuncDesc->elemdescFunc.tdesc.vt == VT_HRESULT, "ret vt %x\n", pFuncDesc->elemdescFunc.tdesc.vt);
710 ok(pFuncDesc->lprgelemdescParam[0].tdesc.vt == VT_I4, "parm 0 vt %x\n", pFuncDesc->lprgelemdescParam[0].tdesc.vt);
711 ok(U(pFuncDesc->lprgelemdescParam[0]).paramdesc.wParamFlags == PARAMFLAG_NONE, "parm 0 flags %x\n", U(pFuncDesc->lprgelemdescParam[0]).paramdesc.wParamFlags);
712
713 ok(pFuncDesc->lprgelemdescParam[1].tdesc.vt == VT_BSTR, "parm 1 vt %x\n", pFuncDesc->lprgelemdescParam[1].tdesc.vt);
714 ok(U(pFuncDesc->lprgelemdescParam[1]).paramdesc.wParamFlags == PARAMFLAG_NONE, "parm 1 flags %x\n", U(pFuncDesc->lprgelemdescParam[1]).paramdesc.wParamFlags);
715 ITypeInfo_ReleaseFuncDesc(pTI2, pFuncDesc);
716
717 hr = ITypeInfo_GetFuncDesc(pTI2, 1, &pFuncDesc);
718 ok(hr == S_OK, "hr %08x\n", hr);
719 ok(pFuncDesc->funckind == FUNC_VIRTUAL, "funckind %d\n", pFuncDesc->funckind);
720 ok(pFuncDesc->invkind == methdata[1].wFlags, "invkind %d\n", pFuncDesc->invkind);
721 ok(pFuncDesc->callconv == methdata[1].cc, "callconv %d\n", pFuncDesc->callconv);
722 ok(pFuncDesc->cParams == methdata[1].cArgs, "cParams %d\n", pFuncDesc->cParams);
723 ok(pFuncDesc->oVft == sizeof(void *), "oVft %d\n", pFuncDesc->oVft);
724 ok(pFuncDesc->wFuncFlags == 0, "oVft %d\n", pFuncDesc->wFuncFlags);
725 ok(pFuncDesc->elemdescFunc.tdesc.vt == VT_I4, "ret vt %x\n", pFuncDesc->elemdescFunc.tdesc.vt);
726 ITypeInfo_ReleaseFuncDesc(pTI2, pFuncDesc);
727
728 hr = ITypeInfo_GetFuncDesc(pTI2, 2, &pFuncDesc);
729 ok(hr == S_OK, "hr %08x\n", hr);
730 ok(pFuncDesc->funckind == FUNC_VIRTUAL, "funckind %d\n", pFuncDesc->funckind);
731 ok(pFuncDesc->invkind == methdata[2].wFlags, "invkind %d\n", pFuncDesc->invkind);
732 ok(pFuncDesc->callconv == methdata[2].cc, "callconv %d\n", pFuncDesc->callconv);
733 ok(pFuncDesc->cParams == methdata[2].cArgs, "cParams %d\n", pFuncDesc->cParams);
734 ok(pFuncDesc->oVft == 3 * sizeof(void *), "oVft %d\n", pFuncDesc->oVft);
735 ok(pFuncDesc->wFuncFlags == 0, "oVft %d\n", pFuncDesc->wFuncFlags);
736 ok(pFuncDesc->elemdescFunc.tdesc.vt == VT_HRESULT, "ret vt %x\n", pFuncDesc->elemdescFunc.tdesc.vt);
737 ok(pFuncDesc->lprgelemdescParam[0].tdesc.vt == VT_I4, "parm 0 vt %x\n", pFuncDesc->lprgelemdescParam[0].tdesc.vt);
738 ok(U(pFuncDesc->lprgelemdescParam[0]).paramdesc.wParamFlags == PARAMFLAG_NONE, "parm 0 flags %x\n", U(pFuncDesc->lprgelemdescParam[0]).paramdesc.wParamFlags);
739 ITypeInfo_ReleaseFuncDesc(pTI2, pFuncDesc);
740
741 hr = ITypeInfo_GetFuncDesc(pTI2, 3, &pFuncDesc);
742 ok(hr == S_OK, "hr %08x\n", hr);
743 ok(pFuncDesc->funckind == FUNC_VIRTUAL, "funckind %d\n", pFuncDesc->funckind);
744 ok(pFuncDesc->invkind == methdata[3].wFlags, "invkind %d\n", pFuncDesc->invkind);
745 ok(pFuncDesc->callconv == methdata[3].cc, "callconv %d\n", pFuncDesc->callconv);
746 ok(pFuncDesc->cParams == methdata[3].cArgs, "cParams %d\n", pFuncDesc->cParams);
747 ok(pFuncDesc->oVft == 4 * sizeof(void *), "oVft %d\n", pFuncDesc->oVft);
748 ok(pFuncDesc->wFuncFlags == 0, "oVft %d\n", pFuncDesc->wFuncFlags);
749 ok(pFuncDesc->elemdescFunc.tdesc.vt == VT_I4, "ret vt %x\n", pFuncDesc->elemdescFunc.tdesc.vt);
750 ITypeInfo_ReleaseFuncDesc(pTI2, pFuncDesc);
751
752 /* test GetIDsOfNames on a coclass to see if it searches its interfaces */
753 hr = ITypeInfo_GetIDsOfNames(pTypeInfo, &name, 1, &memid);
754 ok(hr == S_OK, "hr 0x%08x\n", hr);
755 ok(memid == 0x123, "memid 0x%08x\n", memid);
756
757 ITypeInfo_Release(pTI2);
758 ITypeInfo_Release(pTypeInfo);
759
760 SysFreeString(parms1[0].szName);
761 SysFreeString(parms1[1].szName);
762 SysFreeString(parms3[0].szName);
763 SysFreeString(methdata[0].szName);
764 SysFreeString(methdata[1].szName);
765 SysFreeString(methdata[2].szName);
766 SysFreeString(methdata[3].szName);
767}
768
769static void write_typelib(int res_no, const char *filename)
770{
771 DWORD written;
772 HANDLE file;
773 HRSRC res;
774 void *ptr;
775
777 ok( file != INVALID_HANDLE_VALUE, "file creation failed\n" );
778 if (file == INVALID_HANDLE_VALUE) return;
779 res = FindResourceA( GetModuleHandleA(NULL), (LPCSTR)MAKEINTRESOURCE(res_no), "TYPELIB" );
780 ok( res != 0, "couldn't find resource\n" );
783 ok( written == SizeofResource( GetModuleHandleA(NULL), res ), "couldn't write resource\n" );
784 CloseHandle( file );
785}
786
788{
789 DISPID named_args[3] = { DISPID_THIS };
790 VARIANT args[3], res;
791 DISPPARAMS dp = {args, named_args, 1, 0};
792 UINT i;
794
795 V_VT(args) = VT_INT;
796 V_INT(args) = 3;
797 V_VT(&res) = VT_ERROR;
798 hres = ITypeInfo_Invoke(typeinfo, &invoketest, 3, DISPATCH_METHOD, &dp, &res, NULL, &i);
799 ok(hres == S_OK, "got 0x%08x\n", hres);
800 ok(V_VT(&res) == VT_I4, "got %d\n", V_VT(&res));
801 ok(V_I4(&res) == 4, "got %d\n", V_I4(&res));
802
805 V_VT(args+1) = VT_INT;
806 V_INT(args+1) = 3;
807 V_VT(&res) = VT_ERROR;
808 dp.cNamedArgs = 1;
809 dp.cArgs = 2;
810 hres = ITypeInfo_Invoke(typeinfo, &invoketest, 3, DISPATCH_METHOD, &dp, &res, NULL, &i);
811 ok(hres == DISP_E_BADPARAMCOUNT, "got 0x%08x\n", hres);
812}
813
814static const char *create_test_typelib(int res_no)
815{
816 static char filename[MAX_PATH];
817
818 GetTempFileNameA( ".", "tlb", 0, filename );
819 write_typelib(res_no, filename);
820 return filename;
821}
822
823static void test_TypeInfo(void)
824{
825 ITypeLib *pTypeLib;
826 ITypeInfo *pTypeInfo, *ti;
827 ITypeInfo2 *pTypeInfo2;
828 HRESULT hr;
829 static WCHAR wszBogus[] = { 'b','o','g','u','s',0 };
830 static WCHAR wszGetTypeInfo[] = { 'G','e','t','T','y','p','e','I','n','f','o',0 };
831 static WCHAR wszClone[] = {'C','l','o','n','e',0};
832 OLECHAR* bogus = wszBogus;
833 OLECHAR* pwszGetTypeInfo = wszGetTypeInfo;
834 OLECHAR* pwszClone = wszClone;
835 DISPID dispidMember;
836 DISPPARAMS dispparams;
837 GUID bogusguid = {0x806afb4f,0x13f7,0x42d2,{0x89,0x2c,0x6c,0x97,0xc3,0x6a,0x36,0xc1}};
838 VARIANT var, res, args[2];
839 UINT count, i;
840 TYPEKIND kind;
841 const char *filenameA;
843 TYPEATTR *attr;
844 LONG l;
845
846 hr = LoadTypeLib(wszStdOle2, &pTypeLib);
848
849 count = ITypeLib_GetTypeInfoCount(pTypeLib);
850 ok(count > 0, "got %d\n", count);
851
852 /* invalid index */
853 hr = ITypeLib_GetTypeInfo(pTypeLib, count, &pTypeInfo);
854 ok(hr == TYPE_E_ELEMENTNOTFOUND, "got 0x%08x\n", hr);
855
856 hr = ITypeLib_GetTypeInfo(pTypeLib, 0, NULL);
857 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
858
859 hr = ITypeLib_GetLibAttr(pTypeLib, NULL);
860 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
861
862 hr = ITypeLib_GetTypeInfoType(pTypeLib, count, &kind);
863 ok(hr == TYPE_E_ELEMENTNOTFOUND, "got 0x%08x\n", hr);
864
865 hr = ITypeLib_GetTypeInfoType(pTypeLib, count, NULL);
866 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
867
868 hr = ITypeLib_GetTypeInfoType(pTypeLib, 0, NULL);
869 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
870
871 hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, &IID_IFont, &pTypeInfo);
872 ok_ole_success(hr, ITypeLib_GetTypeInfoOfGuid);
873
874 /* test nonexistent method name */
875 hr = ITypeInfo_GetIDsOfNames(pTypeInfo, &bogus, 1, &dispidMember);
877 "ITypeInfo_GetIDsOfNames should have returned DISP_E_UNKNOWNNAME instead of 0x%08x\n",
878 hr);
879
880 dispparams.cArgs = 0;
881 dispparams.rgdispidNamedArgs = NULL;
882 dispparams.rgvarg = NULL;
883
884 /* test dispparams not NULL */
885
886 /* invalid member id -- wrong flags -- cNamedArgs not bigger than cArgs */
887 dispparams.cNamedArgs = 0;
888 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, 0xdeadbeef, DISPATCH_PROPERTYGET, &dispparams, NULL, NULL, NULL);
889 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
890 /* invalid member id -- correct flags -- cNamedArgs not bigger than cArgs */
891 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, 0xdeadbeef, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
892 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
893
894 /* invalid member id -- wrong flags -- cNamedArgs bigger than cArgs */
895 dispparams.cNamedArgs = 1;
896 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, 0xdeadbeef, DISPATCH_PROPERTYGET, &dispparams, NULL, NULL, NULL);
897 ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr);
898 /* invalid member id -- correct flags -- cNamedArgs bigger than cArgs */
899 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, 0xdeadbeef, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
900 ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr);
901
902
903 hr = ITypeInfo_GetIDsOfNames(pTypeInfo, &pwszClone, 1, &dispidMember);
904 ok_ole_success(hr, ITypeInfo_GetIDsOfNames);
905
906 /* correct member id -- wrong flags -- cNamedArgs not bigger than cArgs */
907 dispparams.cNamedArgs = 0;
908 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, &dispparams, NULL, NULL, NULL);
909 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
910 /* correct member id -- correct flags -- cNamedArgs not bigger than cArgs */
911 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
912 ok(hr == DISP_E_BADPARAMCOUNT, "ITypeInfo_Invoke should have returned DISP_E_BADPARAMCOUNT instead of 0x%08x\n", hr);
913
914 /* correct member id -- wrong flags -- cNamedArgs bigger than cArgs */
915 dispparams.cNamedArgs = 1;
916 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, &dispparams, NULL, NULL, NULL);
917 ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr);
918 /* correct member id -- correct flags -- cNamedArgs bigger than cArgs */
919 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
920 ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr);
921
922 /* test NULL dispparams */
923
924 /* correct member id -- wrong flags -- cNamedArgs not bigger than cArgs */
925 dispparams.cNamedArgs = 0;
926 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, NULL, NULL, NULL, NULL);
927 ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr);
928 /* correct member id -- correct flags -- cNamedArgs not bigger than cArgs */
929 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, NULL, NULL, NULL, NULL);
930 ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr);
931
932 /* correct member id -- wrong flags -- cNamedArgs bigger than cArgs */
933 dispparams.cNamedArgs = 1;
934 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, NULL, NULL, NULL, NULL);
935 ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr);
936 /* correct member id -- correct flags -- cNamedArgs bigger than cArgs */
937 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, NULL, NULL, NULL, NULL);
938 ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr);
939
940 ITypeInfo_Release(pTypeInfo);
941
942 hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, &IID_IDispatch, &pTypeInfo);
943 ok_ole_success(hr, ITypeLib_GetTypeInfoOfGuid);
944
945 hr = ITypeInfo_GetIDsOfNames(pTypeInfo, &pwszGetTypeInfo, 1, &dispidMember);
946 ok_ole_success(hr, ITypeInfo_GetIDsOfNames);
947
948 hr = ITypeInfo_QueryInterface(pTypeInfo, &IID_ITypeInfo2, (void**)&pTypeInfo2);
949 ok_ole_success(hr, ITypeInfo_QueryInterface);
950
951 if (SUCCEEDED(hr))
952 {
954
955 V_VT(&var) = VT_I4;
956
957 /* test unknown guid passed to GetCustData */
958 hr = ITypeInfo2_GetCustData(pTypeInfo2, &bogusguid, &var);
959 ok_ole_success(hr, ITypeInfo_GetCustData);
960 ok(V_VT(&var) == VT_EMPTY, "got %i, expected VT_EMPTY\n", V_VT(&var));
961
962 ITypeInfo2_Release(pTypeInfo2);
963
965 }
966
967 /* Check instance size for IDispatch, typelib is loaded using system SYS_WIN* kind so it always matches
968 system bitness. */
969 hr = ITypeInfo_GetTypeAttr(pTypeInfo, &attr);
970 ok(hr == S_OK, "got 0x%08x\n", hr);
971 ok(attr->cbSizeInstance == sizeof(void*), "got size %d\n", attr->cbSizeInstance);
972 ok(attr->typekind == TKIND_INTERFACE, "got typekind %d\n", attr->typekind);
973 ITypeInfo_ReleaseTypeAttr(pTypeInfo, attr);
974
975 /* same size check with some general interface */
976 hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, &IID_IEnumVARIANT, &ti);
977 ok(hr == S_OK, "got 0x%08x\n", hr);
978 hr = ITypeInfo_GetTypeAttr(ti, &attr);
979 ok(hr == S_OK, "got 0x%08x\n", hr);
980 ok(attr->cbSizeInstance == sizeof(void*), "got size %d\n", attr->cbSizeInstance);
981 ITypeInfo_ReleaseTypeAttr(ti, attr);
982 ITypeInfo_Release(ti);
983
984 /* test invoking a method with a [restricted] keyword */
985
986 /* correct member id -- wrong flags -- cNamedArgs not bigger than cArgs */
987 dispparams.cNamedArgs = 0;
988 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, &dispparams, NULL, NULL, NULL);
989 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
990 /* correct member id -- correct flags -- cNamedArgs not bigger than cArgs */
991 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
992 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
993
994 /* correct member id -- wrong flags -- cNamedArgs bigger than cArgs */
995 dispparams.cNamedArgs = 1;
996 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, &dispparams, NULL, NULL, NULL);
997 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
998 /* correct member id -- correct flags -- cNamedArgs bigger than cArgs */
999 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
1000 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
1001
1002 /* test NULL dispparams */
1003
1004 /* correct member id -- wrong flags -- cNamedArgs not bigger than cArgs */
1005 dispparams.cNamedArgs = 0;
1006 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, NULL, NULL, NULL, NULL);
1007 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
1008 /* correct member id -- correct flags -- cNamedArgs not bigger than cArgs */
1009 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, NULL, NULL, NULL, NULL);
1010 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
1011
1012 /* correct member id -- wrong flags -- cNamedArgs bigger than cArgs */
1013 dispparams.cNamedArgs = 1;
1014 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, NULL, NULL, NULL, NULL);
1015 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
1016 /* correct member id -- correct flags -- cNamedArgs bigger than cArgs */
1017 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, NULL, NULL, NULL, NULL);
1018 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
1019
1020 ITypeInfo_Release(pTypeInfo);
1021 ITypeLib_Release(pTypeLib);
1022
1025 hr = LoadTypeLib(filename, &pTypeLib);
1026 ok(hr == S_OK, "got 0x%08x\n", hr);
1027
1028 hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, &IID_IInvokeTest, &pTypeInfo);
1029 ok(hr == S_OK, "got 0x%08x\n", hr);
1030
1031 dispparams.cArgs = 1;
1032 dispparams.cNamedArgs = 0;
1033 dispparams.rgdispidNamedArgs = NULL;
1034 dispparams.rgvarg = args;
1035
1036 V_VT(&args[0]) = VT_I4;
1037 V_I4(&args[0]) = 0;
1038
1039 i = 0;
1040 V_VT(&res) = VT_EMPTY;
1041 V_I4(&res) = 0;
1042 /* call propget with DISPATCH_METHOD|DISPATCH_PROPERTYGET flags */
1043 hr = ITypeInfo_Invoke(pTypeInfo, &invoketest, DISPID_VALUE, DISPATCH_METHOD|DISPATCH_PROPERTYGET,
1044 &dispparams, &res, NULL, &i);
1045 ok(hr == S_OK, "got 0x%08x\n", hr);
1046 ok(V_VT(&res) == VT_I4, "got %d\n", V_VT(&res));
1047 ok(V_I4(&res) == 1, "got %d\n", V_I4(&res));
1048
1049 i = 0;
1050 /* call propget with DISPATCH_METHOD flags */
1051 hr = ITypeInfo_Invoke(pTypeInfo, &invoketest, DISPID_VALUE, DISPATCH_METHOD,
1052 &dispparams, &res, NULL, &i);
1053 ok(hr == DISP_E_MEMBERNOTFOUND, "got 0x%08x, %d\n", hr, i);
1054
1055 i = 0;
1056 V_VT(&res) = VT_EMPTY;
1057 V_I4(&res) = 0;
1058 hr = ITypeInfo_Invoke(pTypeInfo, &invoketest, DISPID_VALUE, DISPATCH_PROPERTYGET,
1059 &dispparams, &res, NULL, &i);
1060 ok(hr == S_OK, "got 0x%08x, %d\n", hr, i);
1061 ok(V_VT(&res) == VT_I4, "got %d\n", V_VT(&res));
1062 ok(V_I4(&res) == 1, "got %d\n", V_I4(&res));
1063
1064 /* call propget with DISPATCH_METHOD|DISPATCH_PROPERTYGET flags */
1065 V_VT(&args[0]) = VT_I4;
1066 V_I4(&args[0]) = 7;
1067
1068 dispparams.cArgs = 1;
1069 dispparams.rgvarg = args;
1070
1071 i = 0;
1072 V_VT(&res) = VT_EMPTY;
1073 V_I4(&res) = 0;
1074 hr = ITypeInfo_Invoke(pTypeInfo, &invoketest, 4, DISPATCH_METHOD|DISPATCH_PROPERTYGET, &dispparams, &res, NULL, &i);
1075 ok(hr == S_OK, "got 0x%08x, %d\n", hr, i);
1076 ok(V_VT(&res) == VT_I4, "got %d\n", V_VT(&res));
1077 ok(V_I4(&res) == 15, "got %d\n", V_I4(&res));
1078
1079
1080 /* DISPATCH_PROPERTYPUTREF */
1081 l = 1;
1082 V_VT(&args[0]) = VT_I4|VT_BYREF;
1083 V_I4REF(&args[0]) = &l;
1084
1085 dispidMember = DISPID_PROPERTYPUT;
1086 dispparams.cArgs = 1;
1087 dispparams.cNamedArgs = 1;
1088 dispparams.rgdispidNamedArgs = &dispidMember;
1089 dispparams.rgvarg = args;
1090
1091 i = 0;
1092 V_VT(&res) = VT_EMPTY;
1093 V_I4(&res) = 0;
1094 hr = ITypeInfo_Invoke(pTypeInfo, &invoketest, 1, DISPATCH_PROPERTYPUTREF, &dispparams, &res, NULL, &i);
1095 ok(hr == S_OK, "got 0x%08x, %d\n", hr, i);
1096 ok(V_VT(&res) == VT_I4, "got %d\n", V_VT(&res));
1097 ok(V_I4(&res) == 3, "got %d\n", V_I4(&res));
1098
1099 i = 0;
1100 V_VT(&res) = VT_EMPTY;
1101 V_I4(&res) = 0;
1102 hr = ITypeInfo_Invoke(pTypeInfo, &invoketest, 1, DISPATCH_PROPERTYPUT, &dispparams, &res, NULL, &i);
1103 ok(hr == DISP_E_MEMBERNOTFOUND, "got 0x%08x, %d\n", hr, i);
1104
1105 i = 0;
1106 V_VT(&args[0]) = VT_UNKNOWN;
1107 V_UNKNOWN(&args[0]) = NULL;
1108
1109 V_VT(&res) = VT_EMPTY;
1110 V_I4(&res) = 0;
1111 hr = ITypeInfo_Invoke(pTypeInfo, &invoketest, 2, DISPATCH_PROPERTYPUTREF, &dispparams, &res, NULL, &i);
1112 ok(hr == S_OK, "got 0x%08x, %d\n", hr, i);
1113 ok(V_VT(&res) == VT_I4, "got %d\n", V_VT(&res));
1114 ok(V_I4(&res) == 6, "got %d\n", V_I4(&res));
1115
1116 i = 0;
1117 V_VT(&res) = VT_EMPTY;
1118 V_I4(&res) = 0;
1119 hr = ITypeInfo_Invoke(pTypeInfo, &invoketest, 2, DISPATCH_PROPERTYPUT, &dispparams, &res, NULL, &i);
1120 ok(hr == DISP_E_MEMBERNOTFOUND, "got 0x%08x, %d\n", hr, i);
1121
1122 test_invoke_func(pTypeInfo);
1123
1124 ITypeInfo_Release(pTypeInfo);
1125 ITypeLib_Release(pTypeLib);
1127}
1128
1129static int WINAPI int_func( int a0, int a1, int a2, int a3, int a4 )
1130{
1131 ok( a0 == 1, "wrong arg0 %x\n", a0 );
1132 ok( a1 == -1, "wrong arg1 %x\n", a1 );
1133 ok( a2 == (0x55550000 | 1234), "wrong arg2 %x\n", a2 );
1134 ok( a3 == 0xdeadbeef, "wrong arg3 %x\n", a3 );
1135 ok( a4 == 0x555555fd, "wrong arg4 %x\n", a4 );
1136 return 4321;
1137}
1138
1139static double WINAPI double_func( double a0, float a1, double a2, int a3 )
1140{
1141 ok( a0 == 1.2, "wrong arg0 %f\n", a0 );
1142 ok( a1 == 3.25, "wrong arg1 %f\n", (double)a1 );
1143 ok( a2 == 1.2e12, "wrong arg2 %f\n", a2);
1144 ok( a3 == -4433.0, "wrong arg3 %f\n", (double)a3 );
1145 return 4321;
1146}
1147
1149{
1150 ok( a0 == (((ULONGLONG)0xdead << 32) | 0xbeef), "wrong arg0 %08x%08x\n", (DWORD)(a0 >> 32), (DWORD)a0);
1151 ok( a1.int64 == ((ULONGLONG)10000 * 12345678), "wrong arg1 %08x%08x\n",
1152 (DWORD)(a1.int64 >> 32), (DWORD)a1.int64 );
1153 return ((ULONGLONG)4321 << 32) | 8765;
1154}
1155
1157{
1158 VARIANT var;
1159 ok( a0 == 2233, "wrong arg0 %x\n", a0 );
1160 ok( a1 == 1 || broken(a1 == 0x55550001), "wrong arg1 %x\n", a1 );
1161 V_VT(&var) = VT_LPWSTR;
1162 V_UI4(&var) = 0xbabe;
1163 ok( a2.Hi32 == 1122, "wrong arg2.Hi32 %x\n", a2.Hi32 );
1164 ok( U1(a2).Lo64 == 3344, "wrong arg2.Lo64 %08x%08x\n", (DWORD)(U1(a2).Lo64 >> 32), (DWORD)U1(a2).Lo64 );
1165 ok( V_VT(&a3) == VT_EMPTY, "wrong arg3 type %x\n", V_VT(&a3) );
1166 ok( V_UI4(&a3) == 0xdeadbeef, "wrong arg3 value %x\n", V_UI4(&a3) );
1167 return var;
1168}
1169
1170static int CDECL void_func( int a0, int a1 )
1171{
1172 if (is_win64) /* VT_EMPTY is passed as real arg on win64 */
1173 {
1174 ok( a0 == 0x55555555, "wrong arg0 %x\n", a0 );
1175 ok( a1 == 1111, "wrong arg1 %x\n", a1 );
1176 }
1177 else
1178 {
1179 ok( a0 == 1111, "wrong arg0 %x\n", a0 );
1180 ok( a1 == 0, "wrong arg1 %x\n", a1 );
1181 }
1182 return 12;
1183}
1184
1185static int WINAPI stdcall_func( int a )
1186{
1187 return 0;
1188}
1189
1190static int WINAPI inst_func( void *inst, int a )
1191{
1192 ok( (*(void ***)inst)[3] == inst_func, "wrong ptr %p\n", inst );
1193 ok( a == 3, "wrong arg %x\n", a );
1194 return a * 2;
1195}
1196
1198{
1199 return S_FALSE;
1200}
1201
1202static const WCHAR testW[] = { 'T','e','s','t',0 };
1203
1205{
1206 ok(V_VT(&v1) == VT_I4, "unexpected %d\n", V_VT(&v1));
1207 ok(V_I4(&v1) == 2, "unexpected %d\n", V_I4(&v1));
1208 ok(V_VT(&v2) == VT_BSTR, "unexpected %d\n", V_VT(&v2));
1209 ok(lstrcmpW(V_BSTR(&v2), testW) == 0, "unexpected %s\n", wine_dbgstr_w(V_BSTR(&v2)));
1210
1211 V_VT(ret) = VT_UI4;
1212 V_I4(ret) = 4321;
1213}
1214
1215static void WINAPI inst_func2(void *inst, VARIANT *ret, VARIANT v1, VARIANT v2)
1216{
1217 ok( (*(void ***)inst)[3] == inst_func2, "wrong ptr %p\n", inst );
1218
1219 ok(V_VT(ret) == VT_I4 || broken(V_VT(ret) == VT_VARIANT) /* win64 */, "unexpected %d\n", V_VT(ret));
1220 ok(V_I4(ret) == 1234, "unexpected %d\n", V_I4(ret));
1221
1222 ok(V_VT(&v1) == VT_I4, "unexpected %d\n", V_VT(&v1));
1223 ok(V_I4(&v1) == 2, "unexpected %d\n", V_I4(&v1));
1224 ok(V_VT(&v2) == VT_BSTR, "unexpected %d\n", V_VT(&v2));
1225 ok(lstrcmpW(V_BSTR(&v2), testW) == 0, "unexpected %s\n", wine_dbgstr_w(V_BSTR(&v2)));
1226
1227 V_VT(ret) = VT_UI4;
1228 V_I4(ret) = 4321;
1229}
1230
1231static void *vtable[] = { NULL, NULL, NULL, inst_func };
1232static void *vtable2[] = { NULL, NULL, NULL, inst_func2 };
1233
1234static void test_DispCallFunc(void)
1235{
1236 void **inst;
1237 HRESULT res;
1238 VARIANT result, args[5];
1239 VARIANTARG *pargs[5];
1240 VARTYPE types[5];
1241 int i;
1242
1243 for (i = 0; i < 5; i++) pargs[i] = &args[i];
1244
1245 memset( args, 0x55, sizeof(args) );
1246
1247 types[0] = VT_VARIANT;
1248 V_VT(&args[0]) = VT_I4;
1249 V_I4(&args[0]) = 2;
1250 types[1] = VT_VARIANT;
1251 V_VT(&args[1]) = VT_BSTR;
1253 memset( &result, 0xcc, sizeof(result) );
1255 ok(res == S_OK, "DispCallFunc error %#x\n", res);
1256 ok(V_VT(&result) == VT_UI4, "wrong result type %d\n", V_VT(&result));
1257 ok(V_UI4(&result) == 4321, "wrong result %u\n", V_UI4(&result));
1258
1259 V_VT(&result) = VT_I4;
1260 V_UI4(&result) = 1234;
1261 inst = vtable2;
1262 res = DispCallFunc(&inst, 3 * sizeof(void *), CC_STDCALL, VT_VARIANT, 2, types, pargs, &result);
1263 ok(res == S_OK, "DispCallFunc error %#x\n", res);
1264 ok(V_VT(&result) == VT_UI4, "wrong result type %d\n", V_VT(&result));
1265 ok(V_UI4(&result) == 4321, "wrong result %u\n", V_UI4(&result));
1266
1267 VariantClear(&args[1]);
1268
1269 memset( args, 0x55, sizeof(args) );
1270 types[0] = VT_UI4;
1271 V_UI4(&args[0]) = 1;
1272 types[1] = VT_I4;
1273 V_I4(&args[1]) = -1;
1274 types[2] = VT_I2;
1275 V_I2(&args[2]) = 1234;
1276 types[3] = VT_UI4;
1277 V_UI4(&args[3]) = 0xdeadbeef;
1278 types[4] = VT_UI4;
1279 V_I1(&args[4]) = -3;
1280 memset( &result, 0xcc, sizeof(result) );
1282 ok( res == S_OK, "DispCallFunc failed %x\n", res );
1283 ok( V_VT(&result) == VT_UI4, "wrong result type %d\n", V_VT(&result) );
1284 ok( V_UI4(&result) == 4321, "wrong result %u\n", V_UI4(&result) );
1285
1286 /* the function checks the argument sizes for stdcall */
1288 {
1290 ok( res == DISP_E_BADCALLEE, "DispCallFunc wrong error %x\n", res );
1292 ok( res == S_OK, "DispCallFunc failed %x\n", res );
1294 ok( res == DISP_E_BADCALLEE, "DispCallFunc wrong error %x\n", res );
1295 }
1296
1297 memset( args, 0x55, sizeof(args) );
1298 types[0] = VT_R8;
1299 V_R8(&args[0]) = 1.2;
1300 types[1] = VT_R4;
1301 V_R4(&args[1]) = 3.25;
1302 types[2] = VT_R8;
1303 V_R8(&args[2]) = 1.2e12;
1304 types[3] = VT_I4;
1305 V_I4(&args[3]) = -4433;
1306 memset( &result, 0xcc, sizeof(result) );
1308 ok( res == S_OK, "DispCallFunc failed %x\n", res );
1309 ok( V_VT(&result) == VT_R8, "wrong result type %d\n", V_VT(&result) );
1310 ok( V_R8(&result) == 4321, "wrong result %f\n", V_R8(&result) );
1311
1312 memset( args, 0x55, sizeof(args) );
1313 types[0] = VT_I8;
1314 V_I8(&args[0]) = ((ULONGLONG)0xdead << 32) | 0xbeef;
1315 types[1] = VT_CY;
1316 V_CY(&args[1]).int64 = (ULONGLONG)10000 * 12345678;
1317 memset( &result, 0xcc, sizeof(result) );
1319 ok( res == S_OK || broken(res == E_INVALIDARG), /* longlong not supported on <= win2k */
1320 "DispCallFunc failed %x\n", res );
1321 if (res == S_OK)
1322 {
1323 ok( V_VT(&result) == VT_I8, "wrong result type %d\n", V_VT(&result) );
1324 ok( V_I8(&result) == (((ULONGLONG)4321 << 32) | 8765), "wrong result %08x%08x\n",
1325 (DWORD)(V_I8(&result) >> 32), (DWORD)V_I8(&result) );
1326 }
1327
1328 memset( args, 0x55, sizeof(args) );
1329 types[0] = VT_I4;
1330 V_I4(&args[0]) = 2233;
1331 types[1] = VT_BOOL;
1332 V_BOOL(&args[1]) = 1;
1333 types[2] = VT_DECIMAL;
1334 V_DECIMAL(&args[2]).Hi32 = 1122;
1335 U1(V_DECIMAL(&args[2])).Lo64 = 3344;
1336 types[3] = VT_VARIANT;
1337 V_VT(&args[3]) = VT_EMPTY;
1338 V_UI4(&args[3]) = 0xdeadbeef;
1339 types[4] = VT_EMPTY;
1340 memset( &result, 0xcc, sizeof(result) );
1342 ok( res == S_OK, "DispCallFunc failed %x\n", res );
1343 ok( V_VT(&result) == VT_LPWSTR, "wrong result type %d\n", V_VT(&result) );
1344 ok( V_UI4(&result) == 0xbabe, "wrong result %08x\n", V_UI4(&result) );
1345
1346 memset( args, 0x55, sizeof(args) );
1347 types[0] = VT_EMPTY;
1348 types[1] = VT_I4;
1349 V_I4(&args[1]) = 1111;
1350 types[2] = VT_EMPTY;
1351 types[3] = VT_I4;
1352 V_I4(&args[3]) = 0;
1353 types[4] = VT_EMPTY;
1354 memset( &result, 0xcc, sizeof(result) );
1356 ok( res == S_OK, "DispCallFunc failed %x\n", res );
1357 ok( V_VT(&result) == VT_EMPTY, "wrong result type %d\n", V_VT(&result) );
1358 if (is_win64)
1359 ok( V_UI4(&result) == 12, "wrong result %08x\n", V_UI4(&result) );
1360 else
1361 ok( V_UI4(&result) == 0xcccccccc, "wrong result %08x\n", V_UI4(&result) );
1362
1363 memset( args, 0x55, sizeof(args) );
1364 types[0] = VT_I4;
1365 V_I4(&args[0]) = 3;
1366 memset( &result, 0xcc, sizeof(result) );
1367 inst = vtable;
1368 res = DispCallFunc( &inst, 3 * sizeof(void*), CC_STDCALL, VT_I4, 1, types, pargs, &result );
1369 ok( res == S_OK, "DispCallFunc failed %x\n", res );
1370 ok( V_VT(&result) == VT_I4, "wrong result type %d\n", V_VT(&result) );
1371 ok( V_I4(&result) == 6, "wrong result %08x\n", V_I4(&result) );
1372
1373 memset( &result, 0xcc, sizeof(result) );
1375 ok(res == S_OK, "DispCallFunc failed: %08x\n", res);
1376 ok(V_VT(&result) == VT_ERROR, "V_VT(result) = %u\n", V_VT(&result));
1377 ok(V_ERROR(&result) == S_FALSE, "V_ERROR(result) = %08x\n", V_ERROR(&result));
1378
1379 memset( &result, 0xcc, sizeof(result) );
1381 ok(res == E_INVALIDARG, "DispCallFunc failed: %08x\n", res);
1382 ok(V_VT(&result) == 0xcccc, "V_VT(result) = %u\n", V_VT(&result));
1383}
1384
1385/* RegDeleteTreeW from dlls/advapi32/registry.c, plus additional view flag */
1387{
1388 LONG ret;
1389 DWORD dwMaxSubkeyLen, dwMaxValueLen;
1390 DWORD dwMaxLen, dwSize;
1391 WCHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
1392 HKEY hSubKey = hKey;
1394
1395 if(lpszSubKey)
1396 {
1397 ret = RegOpenKeyExW(hKey, lpszSubKey, 0, KEY_READ | view, &hSubKey);
1398 if (ret) return ret;
1399 }
1400
1401 ret = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL,
1402 &dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL);
1403 if (ret) goto cleanup;
1404
1405 dwMaxSubkeyLen++;
1406 dwMaxValueLen++;
1407 dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
1408 if (dwMaxLen > ARRAY_SIZE(szNameBuf))
1409 {
1410 /* Name too big: alloc a buffer for it */
1411 if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR))))
1412 {
1414 goto cleanup;
1415 }
1416 }
1417
1418 /* Recursively delete all the subkeys */
1419 while (TRUE)
1420 {
1421 dwSize = dwMaxLen;
1422 if (RegEnumKeyExW(hSubKey, 0, lpszName, &dwSize, NULL,
1423 NULL, NULL, NULL)) break;
1424
1425 ret = myRegDeleteTreeW(hSubKey, lpszName, view);
1426 if (ret) goto cleanup;
1427 }
1428
1429 if (lpszSubKey)
1430 if (pRegDeleteKeyExW && view != 0)
1431 ret = pRegDeleteKeyExW(hKey, lpszSubKey, view, 0);
1432 else
1433 ret = RegDeleteKeyW(hKey, lpszSubKey);
1434 else
1435 while (TRUE)
1436 {
1437 dwSize = dwMaxLen;
1438 if (RegEnumValueW(hKey, 0, lpszName, &dwSize,
1439 NULL, NULL, NULL, NULL)) break;
1440
1441 ret = RegDeleteValueW(hKey, lpszName);
1442 if (ret) goto cleanup;
1443 }
1444
1445cleanup:
1446 if (lpszName != szNameBuf)
1447 HeapFree(GetProcessHeap(), 0, lpszName);
1448 if(lpszSubKey)
1449 RegCloseKey(hSubKey);
1450 return ret;
1451}
1452
1454{
1455 static const WCHAR typelibW[] = {'T','y','p','e','l','i','b','\\',0};
1456 static const WCHAR formatW[] = {'\\','%','u','.','%','u','\\','0','\\','w','i','n','%','u',0};
1457 static const WCHAR format2W[] = {'%','s','_','%','u','_','%','u','.','d','l','l',0};
1458 WCHAR buf[128];
1459 HKEY hkey;
1460 BOOL ret = TRUE;
1461 DWORD res;
1462
1463 memcpy(buf, typelibW, sizeof(typelibW));
1464 StringFromGUID2(uid, buf + lstrlenW(buf), 40);
1465
1466 if (remove)
1467 {
1468 ok(myRegDeleteTreeW(HKEY_CLASSES_ROOT, buf, 0) == ERROR_SUCCESS, "SHDeleteKey failed\n");
1469 return TRUE;
1470 }
1471
1472 wsprintfW(buf + lstrlenW(buf), formatW, maj, min, arch);
1473
1474 SetLastError(0xdeadbeef);
1476 KEY_WRITE, NULL, &hkey, NULL);
1478 {
1479 win_skip("W-calls are not implemented\n");
1480 return FALSE;
1481 }
1482
1483 if (res != ERROR_SUCCESS)
1484 {
1485 trace("RegCreateKeyExW failed: %u\n", res);
1486 return FALSE;
1487 }
1488
1489 wsprintfW(buf, format2W, base, maj, min);
1490 if (RegSetValueExW(hkey, NULL, 0, REG_SZ,
1491 (BYTE *)buf, (lstrlenW(buf) + 1) * sizeof(WCHAR)) != ERROR_SUCCESS)
1492 {
1493 trace("RegSetValueExW failed\n");
1494 ret = FALSE;
1495 }
1496 RegCloseKey(hkey);
1497 return ret;
1498}
1499
1501{
1502 static const struct test_data
1503 {
1504 WORD maj, min;
1505 HRESULT ret;
1506 const WCHAR path[16];
1507 } td[] = {
1508 { 1, 0, TYPE_E_LIBNOTREGISTERED, { 0 } },
1509 { 3, 0, S_OK, {'f','a','k','e','_','3','_','0','.','d','l','l',0 } },
1510 { 3, 1, S_OK, {'f','a','k','e','_','3','_','1','.','d','l','l',0 } },
1511 { 3, 22, S_OK, {'f','a','k','e','_','3','_','3','7','.','d','l','l',0 } },
1512 { 3, 37, S_OK, {'f','a','k','e','_','3','_','3','7','.','d','l','l',0 } },
1513 { 3, 40, S_OK, {'f','a','k','e','_','3','_','3','7','.','d','l','l',0 } },
1514 { 0xffff, 0xffff, S_OK, {'f','a','k','e','_','5','_','3','7','.','d','l','l',0 } },
1515 { 0xffff, 0, TYPE_E_LIBNOTREGISTERED, { 0 } },
1516 { 3, 0xffff, TYPE_E_LIBNOTREGISTERED, { 0 } },
1517 { 5, 0xffff, TYPE_E_LIBNOTREGISTERED, { 0 } },
1518 { 4, 0, TYPE_E_LIBNOTREGISTERED, { 0 } }
1519 };
1520 static const WCHAR base[] = {'f','a','k','e',0};
1521 static const WCHAR wrongW[] = {'w','r','o','n','g',0};
1522 UINT i;
1524 GUID uid;
1525 WCHAR uid_str[40];
1526 HRESULT ret;
1527 BSTR path;
1528
1529 status = UuidCreate(&uid);
1530 ok(!status || status == RPC_S_UUID_LOCAL_ONLY, "UuidCreate error %08x\n", status);
1531
1532 StringFromGUID2(&uid, uid_str, 40);
1533 /*trace("GUID: %s\n", wine_dbgstr_w(uid_str));*/
1534
1535 if (!do_typelib_reg_key(&uid, 3, 0, arch, base, FALSE)) return;
1536 if (!do_typelib_reg_key(&uid, 3, 1, arch, base, FALSE)) return;
1537 if (!do_typelib_reg_key(&uid, 3, 37, arch, base, FALSE)) return;
1538 if (!do_typelib_reg_key(&uid, 5, 37, arch, base, FALSE)) return;
1539 if (arch == 64 && !do_typelib_reg_key(&uid, 5, 37, 32, wrongW, FALSE)) return;
1540
1541 for (i = 0; i < ARRAY_SIZE(td); i++)
1542 {
1543 ret = QueryPathOfRegTypeLib(&uid, td[i].maj, td[i].min, LOCALE_NEUTRAL, &path);
1544 ok(ret == td[i].ret, "QueryPathOfRegTypeLib(%u.%u) returned %08x\n", td[i].maj, td[i].min, ret);
1545 if (ret == S_OK)
1546 {
1547 ok(!lstrcmpW(td[i].path, path), "typelib %u.%u path doesn't match\n", td[i].maj, td[i].min);
1549 }
1550 }
1551
1552 do_typelib_reg_key(&uid, 0, 0, arch, NULL, TRUE);
1553}
1554
1555static void test_inheritance(void)
1556{
1557 HRESULT hr;
1558 ITypeLib *pTL;
1559 ITypeInfo *pTI, *pTI_p;
1560 TYPEATTR *pTA;
1561 HREFTYPE href;
1562 FUNCDESC *pFD;
1565
1568
1569 hr = LoadTypeLib(path, &pTL);
1570 if(FAILED(hr)) return;
1571
1572
1573 /* ItestIF3 is a syntax 2 dispinterface */
1574 hr = ITypeLib_GetTypeInfoOfGuid(pTL, &DIID_ItestIF3, &pTI);
1575 ok(hr == S_OK, "hr %08x\n", hr);
1576
1577 hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1578 ok(hr == S_OK, "hr %08x\n", hr);
1579 ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
1580 ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1581 ok(pTA->wTypeFlags == TYPEFLAG_FDISPATCHABLE, "typeflags %x\n", pTA->wTypeFlags);
1582 ok(pTA->cFuncs == 6, "cfuncs %d\n", pTA->cFuncs);
1583 ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1584 ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1585
1586 hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
1587 ok(hr == S_OK, "hr %08x\n", hr);
1588 hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1589 ok(hr == S_OK, "hr %08x\n", hr);
1590 hr = ITypeInfo_GetTypeAttr(pTI_p, &pTA);
1591 ok(hr == S_OK, "got %08x\n", hr);
1592 ok(IsEqualGUID(&pTA->guid, &IID_IDispatch), "guid {%08x-....\n", pTA->guid.Data1);
1593 ITypeInfo_ReleaseTypeAttr(pTI_p, pTA);
1594 ITypeInfo_Release(pTI_p);
1595
1596 /* Should have six methods */
1597 hr = ITypeInfo_GetFuncDesc(pTI, 6, &pFD);
1598 ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
1599 hr = ITypeInfo_GetFuncDesc(pTI, 5, &pFD);
1600 ok(hr == S_OK, "hr %08x\n", hr);
1601 ok(pFD->memid == 0x60020000, "memid %08x\n", pFD->memid);
1602 ok(pFD->oVft == 5 * sizeof(void *), "oVft %d\n", pFD->oVft);
1603 ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1604 ITypeInfo_Release(pTI);
1605
1606
1607 /* ItestIF4 is a syntax 1 dispinterface */
1608 hr = ITypeLib_GetTypeInfoOfGuid(pTL, &DIID_ItestIF4, &pTI);
1609 ok(hr == S_OK, "hr %08x\n", hr);
1610
1611 hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1612 ok(hr == S_OK, "hr %08x\n", hr);
1613 ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
1614 ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1615 ok(pTA->wTypeFlags == TYPEFLAG_FDISPATCHABLE, "typeflags %x\n", pTA->wTypeFlags);
1616 ok(pTA->cFuncs == 1, "cfuncs %d\n", pTA->cFuncs);
1617 ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1618 ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1619
1620 hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
1621 ok(hr == S_OK, "hr %08x\n", hr);
1622 hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1623 ok(hr == S_OK, "hr %08x\n", hr);
1624 hr = ITypeInfo_GetTypeAttr(pTI_p, &pTA);
1625 ok(hr == S_OK, "got %08x\n", hr);
1626 ok(IsEqualGUID(&pTA->guid, &IID_IDispatch), "guid {%08x-....\n", pTA->guid.Data1);
1627 ITypeInfo_ReleaseTypeAttr(pTI_p, pTA);
1628 ITypeInfo_Release(pTI_p);
1629 hr = ITypeInfo_GetFuncDesc(pTI, 1, &pFD);
1630 ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
1631 hr = ITypeInfo_GetFuncDesc(pTI, 0, &pFD);
1632 ok(hr == S_OK, "hr %08x\n", hr);
1633 ok(pFD->memid == 0x1c, "memid %08x\n", pFD->memid);
1634 ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1635 ITypeInfo_Release(pTI);
1636
1637
1638 /* ItestIF5 is dual with inherited ifaces which derive from IUnknown but not IDispatch */
1639 hr = ITypeLib_GetTypeInfoOfGuid(pTL, &IID_ItestIF5, &pTI);
1640 ok(hr == S_OK, "hr %08x\n", hr);
1641
1642 hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1643 ok(hr == S_OK, "hr %08x\n", hr);
1644 ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
1645 ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1646 ok(pTA->wTypeFlags == TYPEFLAG_FDUAL, "typeflags %x\n", pTA->wTypeFlags);
1647 ok(pTA->cFuncs == 8, "cfuncs %d\n", pTA->cFuncs);
1648 ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1649 ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1650
1651 hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
1652 ok(hr == S_OK, "hr %08x\n", hr);
1653 hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1654 ok(hr == S_OK, "hr %08x\n", hr);
1655 hr = ITypeInfo_GetTypeAttr(pTI_p, &pTA);
1656 ok(hr == S_OK, "got %08x\n", hr);
1657 ok(IsEqualGUID(&pTA->guid, &IID_IDispatch), "guid {%08x-....\n", pTA->guid.Data1);
1658 ITypeInfo_ReleaseTypeAttr(pTI_p, pTA);
1659 ITypeInfo_Release(pTI_p);
1660 hr = ITypeInfo_GetFuncDesc(pTI, 6, &pFD);
1661 ok(hr == S_OK, "hr %08x\n", hr);
1662 ok(pFD->memid == 0x1234, "memid %08x\n", pFD->memid);
1663 ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1664 ITypeInfo_Release(pTI);
1665
1666 /* ItestIF7 is dual with inherited ifaces which derive from Dispatch */
1667 hr = ITypeLib_GetTypeInfoOfGuid(pTL, &IID_ItestIF7, &pTI);
1668 ok(hr == S_OK, "hr %08x\n", hr);
1669
1670 hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1671 ok(hr == S_OK, "hr %08x\n", hr);
1672 ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
1673 ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1674 ok(pTA->wTypeFlags == (TYPEFLAG_FDISPATCHABLE|TYPEFLAG_FDUAL), "typeflags %x\n", pTA->wTypeFlags);
1675 ok(pTA->cFuncs == 10, "cfuncs %d\n", pTA->cFuncs);
1676 ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1677 ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1678
1679 hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
1680 ok(hr == S_OK, "hr %08x\n", hr);
1681 hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1682 ok(hr == S_OK, "hr %08x\n", hr);
1683 hr = ITypeInfo_GetTypeAttr(pTI_p, &pTA);
1684 ok(hr == S_OK, "got %08x\n", hr);
1685 ok(IsEqualGUID(&pTA->guid, &IID_IDispatch), "guid {%08x-....\n", pTA->guid.Data1);
1686 ITypeInfo_ReleaseTypeAttr(pTI_p, pTA);
1687 ITypeInfo_Release(pTI_p);
1688
1689 hr = ITypeInfo_GetFuncDesc(pTI, 9, &pFD);
1690 ok(hr == S_OK, "hr %08x\n", hr);
1691 ok(pFD->memid == 0x1236, "memid %08x\n", pFD->memid);
1692 ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1693 ITypeInfo_Release(pTI);
1694
1695 /* ItestIF10 is a syntax 2 dispinterface which doesn't derive from IUnknown */
1696 hr = ITypeLib_GetTypeInfoOfGuid(pTL, &DIID_ItestIF10, &pTI);
1697 ok(hr == S_OK, "hr %08x\n", hr);
1698
1699 hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1700 ok(hr == S_OK, "hr %08x\n", hr);
1701 ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
1702 ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1703 ok(pTA->wTypeFlags == TYPEFLAG_FDISPATCHABLE, "typeflags %x\n", pTA->wTypeFlags);
1704 ok(pTA->cFuncs == 3, "cfuncs %d\n", pTA->cFuncs);
1705 ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1706 ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1707
1708 hr = ITypeInfo_GetRefTypeOfImplType(pTI, -1, &href);
1709 ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
1710 hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
1711 ok(hr == S_OK, "hr %08x\n", hr);
1712 hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1713 ok(hr == S_OK, "hr %08x\n", hr);
1714 hr = ITypeInfo_GetTypeAttr(pTI_p, &pTA);
1715 ok(hr == S_OK, "got %08x\n", hr);
1716 ok(IsEqualGUID(&pTA->guid, &IID_IDispatch), "guid {%08x-....\n", pTA->guid.Data1);
1717 ITypeInfo_ReleaseTypeAttr(pTI_p, pTA);
1718 ITypeInfo_Release(pTI_p);
1719
1720 /* Should have three methods */
1721 hr = ITypeInfo_GetFuncDesc(pTI, 3, &pFD);
1722 ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
1723 hr = ITypeInfo_GetFuncDesc(pTI, 2, &pFD);
1724 ok(hr == S_OK, "hr %08x\n", hr);
1725 ok(pFD->memid == 0x60010000, "memid %08x\n", pFD->memid);
1726 ok(pFD->oVft == 2 * sizeof(void *), "oVft %d\n", pFD->oVft);
1727 ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1728 ITypeInfo_Release(pTI);
1729
1730 /* ItestIF11 is a syntax 2 dispinterface which derives from IDispatch */
1731 hr = ITypeLib_GetTypeInfoOfGuid(pTL, &DIID_ItestIF11, &pTI);
1732 ok(hr == S_OK, "hr %08x\n", hr);
1733
1734 hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1735 ok(hr == S_OK, "hr %08x\n", hr);
1736 ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
1737 ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1738 ok(pTA->wTypeFlags == TYPEFLAG_FDISPATCHABLE, "typeflags %x\n", pTA->wTypeFlags);
1739 ok(pTA->cFuncs == 10, "cfuncs %d\n", pTA->cFuncs);
1740 ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1741 ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1742
1743 hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
1744 ok(hr == S_OK, "hr %08x\n", hr);
1745 hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1746 ok(hr == S_OK, "hr %08x\n", hr);
1747 hr = ITypeInfo_GetTypeAttr(pTI_p, &pTA);
1748 ok(hr == S_OK, "got %08x\n", hr);
1749 ok(IsEqualGUID(&pTA->guid, &IID_IDispatch), "guid {%08x-....\n", pTA->guid.Data1);
1750 ITypeInfo_ReleaseTypeAttr(pTI_p, pTA);
1751 ITypeInfo_Release(pTI_p);
1752
1753 /* Should have ten methods */
1754 hr = ITypeInfo_GetFuncDesc(pTI, 10, &pFD);
1755 ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
1756 hr = ITypeInfo_GetFuncDesc(pTI, 9, &pFD);
1757 ok(hr == S_OK, "hr %08x\n", hr);
1758 ok(pFD->memid == 0x1236, "memid %08x\n", pFD->memid);
1759 ok(pFD->oVft == 9 * sizeof(void *), "oVft %d\n", pFD->oVft);
1760
1761 /* first argument to 10th function is an HREFTYPE from the impl type */
1762 ok(pFD->cParams == 1, "cParams %i\n", pFD->cParams);
1763 ok(pFD->lprgelemdescParam[0].tdesc.vt == VT_USERDEFINED,
1764 "vt 0x%x\n", pFD->lprgelemdescParam[0].tdesc.vt);
1765 href = U(pFD->lprgelemdescParam[0].tdesc).hreftype;
1766 ok((href & 0xff000000) == 0x04000000, "href 0x%08x\n", href);
1767 hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1768 ok(hr == S_OK, "hr %08x\n", hr);
1769 if (SUCCEEDED(hr)) ITypeInfo_Release(pTI_p);
1770 ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1771 ITypeInfo_Release(pTI);
1772
1773
1774 /* ItestIF2 is an interface which derives from IUnknown */
1775 hr = ITypeLib_GetTypeInfoOfGuid(pTL, &IID_ItestIF2, &pTI);
1776 ok(hr == S_OK, "hr %08x\n", hr);
1777
1778 hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1779 ok(hr == S_OK, "hr %08x\n", hr);
1780 ok(pTA->typekind == TKIND_INTERFACE, "kind %04x\n", pTA->typekind);
1781 ok(pTA->cbSizeVft == 6 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1782 ok(pTA->wTypeFlags == 0, "typeflags %x\n", pTA->wTypeFlags);
1783 ok(pTA->cFuncs == 1, "cfuncs %d\n", pTA->cFuncs);
1784 ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1785 ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1786
1787 /* Should have one method */
1788 hr = ITypeInfo_GetFuncDesc(pTI, 1, &pFD);
1789 ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
1790 hr = ITypeInfo_GetFuncDesc(pTI, 0, &pFD);
1791 ok(hr == S_OK, "hr %08x\n", hr);
1792 ok(pFD->memid == 0x60020000, "memid %08x\n", pFD->memid);
1793 ok(pFD->oVft == 5 * sizeof(void *), "oVft %d\n", pFD->oVft);
1794 ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1795 ITypeInfo_Release(pTI);
1796
1797 ITypeLib_Release(pTL);
1798
1799 return;
1800}
1801
1802static void test_CreateTypeLib(SYSKIND sys) {
1803 static OLECHAR typelibW[] = {'t','y','p','e','l','i','b',0};
1804 static OLECHAR helpfileW[] = {'C',':','\\','b','o','g','u','s','.','h','l','p',0};
1805 static OLECHAR interface1W[] = {'i','n','t','e','r','f','a','c','e','1',0};
1806 static OLECHAR interface2W[] = {'i','n','t','e','r','f','a','c','e','2',0};
1807 static OLECHAR interface3W[] = {'i','n','t','e','r','f','a','c','e','3',0};
1808 static OLECHAR dualW[] = {'d','u','a','l',0};
1809 static OLECHAR coclassW[] = {'c','o','c','l','a','s','s',0};
1810 static const WCHAR defaultW[] = {'d','e','f','a','u','l','t',0x3213,0};
1811 static OLECHAR func1W[] = {'f','u','n','c','1',0};
1812 static OLECHAR func2W[] = {'f','u','n','c','2',0};
1813 static OLECHAR prop1W[] = {'P','r','o','p','1',0};
1814 static OLECHAR param1W[] = {'p','a','r','a','m','1',0};
1815 static OLECHAR param2W[] = {'p','a','r','a','m','2',0};
1816 static OLECHAR asdfW[] = {'A','s','d','f',0};
1817 static OLECHAR aliasW[] = {'a','l','i','a','s',0};
1818 static OLECHAR invokeW[] = {'I','n','v','o','k','e',0};
1819 static OLECHAR *names1[] = {func1W, param1W, param2W};
1820 static OLECHAR *names2[] = {func2W, param1W, param2W};
1821 static OLECHAR *propname[] = {prop1W, param1W};
1822 static const GUID tlcustguid = {0xbf611abe,0x5b38,0x11df,{0x91,0x5c,0x08,0x02,0x79,0x79,0x94,0x69}};
1823 static const GUID custguid = {0xbf611abe,0x5b38,0x11df,{0x91,0x5c,0x08,0x02,0x79,0x79,0x94,0x70}};
1824 static const GUID bogusguid = {0xbf611abe,0x5b38,0x11df,{0x91,0x5c,0x08,0x02,0x79,0x79,0x94,0x71}};
1825 static const GUID interfaceguid = {0x3b9ff02f,0x9675,0x4861,{0xb7,0x81,0xce,0xae,0xa4,0x78,0x2a,0xcc}};
1826 static const GUID interface2guid = {0x3b9ff02f,0x9675,0x4861,{0xb7,0x81,0xce,0xae,0xa4,0x78,0x2a,0xcd}};
1827
1828 char filename[MAX_PATH];
1830 ICreateTypeLib2 *createtl;
1831 ICreateTypeInfo *createti;
1832 ICreateTypeInfo2 *createti2;
1833 ITypeLib *tl, *stdole;
1834 ITypeLib2 *tl2;
1835 ITypeInfo *interface1, *interface2, *dual, *unknown, *dispatch, *ti;
1836 ITypeInfo *tinfos[2];
1837 ITypeInfo2 *ti2;
1838 ITypeComp *tcomp, *tcomp2;
1839 MEMBERID memids[2];
1840 FUNCDESC funcdesc, *pfuncdesc;
1841 ELEMDESC elemdesc[5], *edesc;
1842 PARAMDESCEX paramdescex;
1843 TYPEDESC typedesc1, typedesc2;
1844 TYPEATTR *typeattr;
1845 TLIBATTR *libattr;
1846 HREFTYPE hreftype;
1847 BSTR name, docstring, helpfile, names[3];
1848 DWORD helpcontext, ptr_size, alignment;
1849 int impltypeflags;
1850 unsigned int cnames;
1851 USHORT found;
1852 VARIANT cust_data;
1853 HRESULT hres;
1854 TYPEKIND kind;
1855 DESCKIND desckind;
1856 BINDPTR bindptr;
1857 char nameA[16];
1858 WCHAR nameW[16];
1859
1860 switch(sys){
1861 case SYS_WIN32:
1862 trace("testing SYS_WIN32\n");
1863 ptr_size = 4;
1864 alignment = sizeof(void*);
1865 break;
1866 case SYS_WIN64:
1867 trace("testing SYS_WIN64\n");
1868 ptr_size = 8;
1869 alignment = 4;
1870 break;
1871 default:
1872 return;
1873 }
1874
1875 trace("CreateTypeLib tests\n");
1876
1878 ok(hres == S_OK, "got %08x\n", hres);
1879
1880 hres = ITypeLib_GetTypeInfoOfGuid(stdole, &IID_IUnknown, &unknown);
1881 ok(hres == S_OK, "got %08x\n", hres);
1882
1883 hres = ITypeInfo_GetTypeAttr(unknown, &typeattr);
1884 ok(hres == S_OK, "got %08x\n", hres);
1885 ok(typeattr->cbSizeVft == 3 * sizeof(void*), "Got wrong cbSizeVft: %u\n", typeattr->cbSizeVft);
1886 ITypeInfo_ReleaseTypeAttr(unknown, typeattr);
1887
1888 hres = ITypeLib_GetTypeInfoOfGuid(stdole, &IID_IDispatch, &dispatch);
1889 ok(hres == S_OK, "got %08x\n", hres);
1890
1891 GetTempFileNameA(".", "tlb", 0, filename);
1893
1894 hres = CreateTypeLib2(sys, filenameW, &createtl);
1895 ok(hres == S_OK, "got %08x\n", hres);
1896
1897 hres = ICreateTypeLib2_QueryInterface(createtl, &IID_ITypeLib, (void**)&tl);
1898 ok(hres == S_OK, "got %08x\n", hres);
1899
1900 hres = ITypeLib_GetTypeInfo(tl, 0, NULL);
1901 ok(hres == E_INVALIDARG, "got 0x%08x\n", hres);
1902
1903 hres = ITypeLib_GetTypeInfoType(tl, 0, &kind);
1904 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got 0x%08x\n", hres);
1905
1906 hres = ITypeLib_GetTypeInfoType(tl, 0, NULL);
1907 ok(hres == E_INVALIDARG, "got 0x%08x\n", hres);
1908
1909 hres = ITypeLib_GetTypeInfoType(tl, 0, NULL);
1910 ok(hres == E_INVALIDARG, "got 0x%08x\n", hres);
1911
1912 hres = ITypeLib_GetLibAttr(tl, NULL);
1913 ok(hres == E_INVALIDARG, "got %08x\n", hres);
1914
1915 hres = ITypeLib_GetLibAttr(tl, &libattr);
1916 ok(hres == S_OK, "got %08x\n", hres);
1917
1918 ok(libattr->syskind == sys, "syskind = %d\n", libattr->syskind);
1919 ok(libattr->wMajorVerNum == 0, "wMajorVer = %d\n", libattr->wMajorVerNum);
1920 ok(libattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", libattr->wMinorVerNum);
1921 ok(libattr->wLibFlags == 0, "wLibFlags = %d\n", libattr->wLibFlags);
1922
1923 ITypeLib_ReleaseTLibAttr(tl, libattr);
1924
1925 name = (BSTR)0xdeadbeef;
1926 hres = ITypeLib_GetDocumentation(tl, -1, &name, &docstring, &helpcontext, &helpfile);
1927 ok(hres == S_OK, "got %08x\n", hres);
1928 ok(name == NULL, "name != NULL\n");
1929 ok(docstring == NULL, "docstring != NULL\n");
1930 ok(helpcontext == 0, "helpcontext != 0\n");
1931 ok(helpfile == NULL, "helpfile != NULL\n");
1932
1933 hres = ITypeLib_GetDocumentation(tl, 0, &name, NULL, NULL, NULL);
1934 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
1935
1936 hres = ICreateTypeLib2_SetName(createtl, typelibW);
1937 ok(hres == S_OK, "got %08x\n", hres);
1938
1939 hres = ICreateTypeLib2_SetHelpFileName(createtl, helpfileW);
1940 ok(hres == S_OK, "got %08x\n", hres);
1941
1942 hres = ITypeLib_GetDocumentation(tl, -1, NULL, NULL, NULL, NULL);
1943 ok(hres == S_OK, "got %08x\n", hres);
1944
1945 hres = ITypeLib_GetDocumentation(tl, -1, &name, NULL, NULL, &helpfile);
1946 ok(hres == S_OK, "got %08x\n", hres);
1947 ok(!memcmp(name, typelibW, sizeof(typelibW)), "name = %s\n", wine_dbgstr_w(name));
1948 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "helpfile = %s\n", wine_dbgstr_w(helpfile));
1949
1952
1953 V_VT(&cust_data) = VT_I4;
1954 V_I4(&cust_data) = 1;
1955 hres = ICreateTypeLib2_SetCustData(createtl, &tlcustguid, &cust_data);
1956 ok(hres == S_OK, "got %08x\n", hres);
1957
1958 hres = ITypeLib_QueryInterface(tl, &IID_ITypeLib2, (void**)&tl2);
1959 ok(hres == S_OK, "no ITypeLib2 interface (%x)\n", hres);
1960
1961 V_VT(&cust_data) = VT_EMPTY;
1962 V_I4(&cust_data) = 0;
1963 hres = ITypeLib2_GetCustData(tl2, &tlcustguid, &cust_data);
1964 ok(hres == S_OK, "got %08x\n", hres);
1965 ok(V_VT(&cust_data) == VT_I4, "V_VT(&cust_data) = %d\n", V_VT(&cust_data));
1966 ok(V_I4(&cust_data) == 1, "V_I4(&cust_data) = %d\n", V_I4(&cust_data));
1967
1968 ITypeLib2_Release(tl2);
1969
1970 /* invalid parameters */
1971 hres = ICreateTypeLib2_CreateTypeInfo(createtl, NULL, TKIND_INTERFACE, &createti);
1972 ok(hres == E_INVALIDARG, "got %08x\n", hres);
1973
1974 hres = ICreateTypeLib2_CreateTypeInfo(createtl, interface1W, TKIND_INTERFACE, NULL);
1975 ok(hres == E_INVALIDARG, "got %08x\n", hres);
1976
1977 hres = ICreateTypeLib2_CreateTypeInfo(createtl, NULL, TKIND_INTERFACE, NULL);
1978 ok(hres == E_INVALIDARG, "got %08x\n", hres);
1979
1980 hres = ICreateTypeLib2_CreateTypeInfo(createtl, interface1W, TKIND_INTERFACE, &createti);
1981 ok(hres == S_OK, "got %08x\n", hres);
1982
1983 hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&interface1);
1984 ok(hres == S_OK, "got %08x\n", hres);
1985
1986 hres = ITypeLib_GetDocumentation(tl, 0, &name, NULL, NULL, NULL);
1987 ok(hres == S_OK, "got %08x\n", hres);
1988 ok(!memcmp(name, interface1W, sizeof(interface1W)), "name = %s\n", wine_dbgstr_w(name));
1989
1991
1992 ITypeLib_Release(tl);
1993
1994 name = (BSTR)0xdeadbeef;
1995 helpfile = (BSTR)0xdeadbeef;
1996 hres = ITypeInfo_GetDocumentation(interface1, -1, &name, &docstring, &helpcontext, &helpfile);
1997 ok(hres == S_OK, "got %08x\n", hres);
1998 ok(!memcmp(name, interface1W, sizeof(interface1W)), "name = %s\n", wine_dbgstr_w(name));
1999 ok(docstring == NULL, "docstring != NULL\n");
2000 ok(helpcontext == 0, "helpcontext != 0\n");
2001 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "helpfile = %s\n", wine_dbgstr_w(helpfile));
2002
2005
2006 hres = ITypeInfo_GetDocumentation(interface1, 0, &name, NULL, NULL, NULL);
2007 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2008
2009 hres = ITypeInfo_GetRefTypeInfo(interface1, 0, NULL);
2010 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2011
2012
2013 hres = ICreateTypeInfo_LayOut(createti);
2014 ok(hres == S_OK, "got %08x\n", hres);
2015
2016 hres = ICreateTypeInfo_SetGuid(createti, &interfaceguid);
2017 ok(hres == S_OK, "got %08x\n", hres);
2018
2019 hres = ICreateTypeInfo_AddRefTypeInfo(createti, NULL, &hreftype);
2020 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2021
2022 hres = ICreateTypeInfo_AddRefTypeInfo(createti, unknown, NULL);
2023 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2024
2025 hres = ICreateTypeInfo_AddRefTypeInfo(createti, unknown, &hreftype);
2026 ok(hres == S_OK, "got %08x\n", hres);
2027 if(hres != S_OK) {
2028 skip("Skipping some tests\n");
2029 return;
2030 }
2031
2032 hres = ICreateTypeInfo_AddImplType(createti, 1, hreftype);
2033 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2034
2035 hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype);
2036 ok(hres == S_OK, "got %08x\n", hres);
2037
2038 hres = ITypeInfo_GetRefTypeOfImplType(interface1, 0, &hreftype);
2039 ok(hres == S_OK, "got %08x\n", hres);
2040 ok(hreftype == 3, "hreftype = %d\n", hreftype);
2041
2042 hres = ITypeInfo_GetRefTypeInfo(interface1, hreftype, &ti);
2043 ok(hres == S_OK, "got %08x\n", hres);
2044
2045 hres = ITypeInfo_GetTypeAttr(ti, &typeattr);
2046 ok(hres == S_OK, "got %08x\n", hres);
2047 ok(typeattr->cbSizeVft == 3 * ptr_size, "retrieved IUnknown gave wrong cbSizeVft: %u\n", typeattr->cbSizeVft);
2048 ITypeInfo_ReleaseTypeAttr(ti, typeattr);
2049
2050 ITypeInfo_Release(ti);
2051
2052 hres = ITypeInfo_GetRefTypeOfImplType(interface1, -1, &hreftype);
2053 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2054
2055 ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo2, (void**)&ti2);
2056
2057 memset(&funcdesc, 0, sizeof(FUNCDESC));
2058 funcdesc.funckind = FUNC_PUREVIRTUAL;
2059 funcdesc.invkind = INVOKE_PROPERTYGET;
2060 funcdesc.callconv = CC_STDCALL;
2061 funcdesc.elemdescFunc.tdesc.vt = VT_BSTR;
2062 U(funcdesc.elemdescFunc).idldesc.wIDLFlags = IDLFLAG_NONE;
2063
2064 hres = ICreateTypeInfo_AddFuncDesc(createti, 0, NULL);
2065 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2066
2067 hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc);
2068 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2069
2070 hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc);
2071 ok(hres == S_OK, "got %08x\n", hres);
2072
2073 hres = ITypeInfo2_GetFuncDesc(ti2, 0, NULL);
2074 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2075
2076 hres = ITypeInfo2_GetFuncDesc(ti2, 1, &pfuncdesc);
2077 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2078
2079 hres = ITypeInfo2_GetFuncDesc(ti2, 0, &pfuncdesc);
2080 ok(hres == S_OK, "got %08x\n", hres);
2081
2082 ok(pfuncdesc->memid == 0, "got %x\n", pfuncdesc->memid);
2083 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2084 ok(pfuncdesc->lprgelemdescParam == NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2085 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2086 ok(pfuncdesc->invkind == INVOKE_PROPERTYGET, "got 0x%x\n", pfuncdesc->invkind);
2087 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2088 ok(pfuncdesc->cParams == 0, "got %d\n", pfuncdesc->cParams);
2089 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2090 ok(pfuncdesc->oVft == 3 * ptr_size, "got %d\n", pfuncdesc->oVft);
2091 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2092 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_BSTR, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2093 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2094
2095 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2096
2097 hres = ICreateTypeInfo_SetFuncHelpContext(createti, 0, 0xabcdefab);
2098 ok(hres == S_OK, "got %08x\n", hres);
2099
2100 funcdesc.invkind = INVOKE_PROPERTYPUT;
2101 hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc);
2102 ok(hres == TYPE_E_INCONSISTENTPROPFUNCS, "got %08x\n", hres);
2103
2104 funcdesc.invkind = INVOKE_PROPERTYPUTREF;
2105 hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc);
2106 ok(hres == TYPE_E_INCONSISTENTPROPFUNCS, "got %08x\n", hres);
2107
2108 elemdesc[0].tdesc.vt = VT_BSTR;
2109 U(elemdesc[0]).idldesc.dwReserved = 0;
2110 U(elemdesc[0]).idldesc.wIDLFlags = IDLFLAG_FIN;
2111
2112 funcdesc.lprgelemdescParam = elemdesc;
2113 funcdesc.invkind = INVOKE_PROPERTYPUT;
2114 funcdesc.cParams = 1;
2115 funcdesc.elemdescFunc.tdesc.vt = VT_VOID;
2116
2117 hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc);
2118 ok(hres == S_OK, "got %08x\n", hres);
2119
2120 hres = ICreateTypeInfo_SetFuncHelpContext(createti, 1, 0xabcdefab);
2121 ok(hres == S_OK, "got %08x\n", hres);
2122
2123 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, propname, 0);
2124 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2125
2126 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, NULL, 1);
2127 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2128
2129 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, propname, 1);
2130 ok(hres == S_OK, "got %08x\n", hres);
2131
2132 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 1, propname, 1);
2133 ok(hres == S_OK, "got %08x\n", hres);
2134
2135 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 1, propname, 2);
2136 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2137
2138 hres = ITypeInfo2_GetFuncDesc(ti2, 1, &pfuncdesc);
2139 ok(hres == S_OK, "got %08x\n", hres);
2140
2141 ok(pfuncdesc->memid == 0, "got %x\n", pfuncdesc->memid);
2142 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2143 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2144 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2145 ok(pfuncdesc->invkind == INVOKE_PROPERTYPUT, "got 0x%x\n", pfuncdesc->invkind);
2146 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2147 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2148 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2149 ok(pfuncdesc->oVft == 4 * ptr_size, "got %d\n", pfuncdesc->oVft);
2150 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2151 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2152 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2153
2154 edesc = pfuncdesc->lprgelemdescParam;
2155 ok(edesc->tdesc.vt == VT_BSTR, "got: %d\n", edesc->tdesc.vt);
2156 ok(U(*edesc).idldesc.wIDLFlags == IDLFLAG_FIN, "got: %x\n", U(*edesc).idldesc.wIDLFlags);
2157
2158 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2159
2160
2161 funcdesc.invkind = INVOKE_PROPERTYPUTREF;
2162 hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc);
2163 ok(hres == S_OK, "got %08x\n", hres);
2164
2165 hres = ICreateTypeInfo_SetFuncHelpContext(createti, 0, 0xabcdefab);
2166 ok(hres == S_OK, "got %08x\n", hres);
2167
2168 hres = ICreateTypeInfo_SetFuncHelpContext(createti, 0, 0x201);
2169 ok(hres == S_OK, "got %08x\n", hres);
2170
2171 funcdesc.memid = 1;
2172 funcdesc.lprgelemdescParam = NULL;
2173 funcdesc.invkind = INVOKE_FUNC;
2174 funcdesc.cParams = 0;
2175 funcdesc.cScodes = 1;
2176 funcdesc.lprgscode = NULL;
2177 hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc);
2178 ok(hres == S_OK, "got %08x\n", hres);
2179
2180 hres = ITypeInfo2_GetFuncDesc(ti2, 1, &pfuncdesc);
2181 ok(hres == S_OK, "got %08x\n", hres);
2182
2183 ok(pfuncdesc->memid == 1, "got %d\n", pfuncdesc->memid);
2184 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2185 ok(pfuncdesc->lprgelemdescParam == NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2186 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2187 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2188 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2189 ok(pfuncdesc->cParams == 0, "got %d\n", pfuncdesc->cParams);
2190 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2191 ok(pfuncdesc->oVft == 4 * ptr_size, "got %d\n", pfuncdesc->oVft);
2192 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2193 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2194 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2195
2196 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2197
2198 funcdesc.memid = MEMBERID_NIL;
2199 hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc);
2200 ok(hres == S_OK, "got %08x\n", hres);
2201
2202 elemdesc[0].tdesc.vt = VT_PTR;
2203 U(elemdesc[0].tdesc).lptdesc = &typedesc1;
2204 typedesc1.vt = VT_BSTR;
2205 funcdesc.cParams = 1;
2206 funcdesc.lprgelemdescParam = elemdesc;
2207 hres = ICreateTypeInfo_AddFuncDesc(createti, 4, &funcdesc);
2208 ok(hres == S_OK, "got %08x\n", hres);
2209
2210 hres = ITypeInfo2_GetFuncDesc(ti2, 4, &pfuncdesc);
2211 ok(hres == S_OK, "got %08x\n", hres);
2212
2213 ok(pfuncdesc->memid == 0x60010004, "got %x\n", pfuncdesc->memid);
2214 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2215 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2216 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2217 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2218 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2219 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2220 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2221 ok(pfuncdesc->oVft == 7 * ptr_size, "got %d\n", pfuncdesc->oVft);
2222 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2223 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2224 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2225
2226 edesc = pfuncdesc->lprgelemdescParam;
2227 ok(edesc->tdesc.vt == VT_PTR, "got: %d\n", edesc->tdesc.vt);
2228 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FIN, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2229 ok(U(*edesc).paramdesc.pparamdescex == NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2230 ok(U(edesc->tdesc).lptdesc != NULL, "got: %p\n", U(edesc->tdesc).lptdesc);
2231 ok(U(edesc->tdesc).lptdesc->vt == VT_BSTR, "got: %d\n", U(edesc->tdesc).lptdesc->vt);
2232
2233 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2234
2235 U(elemdesc[0].tdesc).lptdesc = &typedesc2;
2236 typedesc2.vt = VT_PTR;
2237 U(typedesc2).lptdesc = &typedesc1;
2238 hres = ICreateTypeInfo_AddFuncDesc(createti, 4, &funcdesc);
2239 ok(hres == S_OK, "got %08x\n", hres);
2240
2241 hres = ITypeInfo2_GetFuncDesc(ti2, 4, &pfuncdesc);
2242 ok(hres == S_OK, "got %08x\n", hres);
2243
2244 ok(pfuncdesc->memid == 0x60010007, "got %x\n", pfuncdesc->memid);
2245 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2246 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2247 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2248 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2249 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2250 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2251 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2252 ok(pfuncdesc->oVft == 7 * ptr_size, "got %d\n", pfuncdesc->oVft);
2253 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2254 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2255 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2256
2257 edesc = pfuncdesc->lprgelemdescParam;
2258 ok(edesc->tdesc.vt == VT_PTR, "got: %d\n", edesc->tdesc.vt);
2259 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FIN, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2260 ok(U(*edesc).paramdesc.pparamdescex == NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2261 ok(U(edesc->tdesc).lptdesc != NULL, "got: %p\n", U(edesc->tdesc).lptdesc);
2262 ok(U(edesc->tdesc).lptdesc->vt == VT_PTR, "got: %d\n", U(edesc->tdesc).lptdesc->vt);
2263 ok(U(*U(edesc->tdesc).lptdesc).lptdesc != NULL, "got: %p\n", U(*U(edesc->tdesc).lptdesc).lptdesc);
2264 ok(U(*U(edesc->tdesc).lptdesc).lptdesc->vt == VT_BSTR, "got: %d\n", U(*U(edesc->tdesc).lptdesc).lptdesc->vt);
2265
2266 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2267
2268 elemdesc[0].tdesc.vt = VT_INT;
2269 U(elemdesc[0]).paramdesc.wParamFlags = PARAMFLAG_FHASDEFAULT;
2270 U(elemdesc[0]).paramdesc.pparamdescex = &paramdescex;
2271 V_VT(&paramdescex.varDefaultValue) = VT_INT;
2272 V_INT(&paramdescex.varDefaultValue) = 0x123;
2273 hres = ICreateTypeInfo_AddFuncDesc(createti, 3, &funcdesc);
2274 ok(hres == S_OK, "got %08x\n", hres);
2275
2276 hres = ITypeInfo2_GetFuncDesc(ti2, 3, &pfuncdesc);
2277 ok(hres == S_OK, "got %08x\n", hres);
2278
2279 ok(pfuncdesc->memid == 0x60010003, "got %x\n", pfuncdesc->memid);
2280 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2281 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2282 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2283 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2284 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2285 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2286 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2287 ok(pfuncdesc->oVft == 6 * ptr_size, "got %d\n", pfuncdesc->oVft);
2288 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2289 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2290 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2291
2292 edesc = pfuncdesc->lprgelemdescParam;
2293 ok(edesc->tdesc.vt == VT_INT, "got: %d\n", edesc->tdesc.vt);
2294 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2295 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2296 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
2297 U(*edesc).paramdesc.pparamdescex->cBytes);
2298 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_I4, "got: %d\n",
2299 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2300 ok(V_I4(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0x123, "got: 0x%x\n",
2301 V_I4(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2302
2303 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2304
2305 U(elemdesc[0]).idldesc.dwReserved = 0;
2306 U(elemdesc[0]).idldesc.wIDLFlags = IDLFLAG_FIN;
2307 elemdesc[1].tdesc.vt = VT_UI2;
2308 U(elemdesc[1]).paramdesc.wParamFlags = PARAMFLAG_FHASDEFAULT;
2309 U(elemdesc[1]).paramdesc.pparamdescex = &paramdescex;
2310 V_VT(&paramdescex.varDefaultValue) = VT_UI2;
2311 V_UI2(&paramdescex.varDefaultValue) = 0xffff;
2312 funcdesc.cParams = 2;
2313 hres = ICreateTypeInfo_AddFuncDesc(createti, 3, &funcdesc);
2314 ok(hres == S_OK, "got %08x\n", hres);
2315
2316 hres = ITypeInfo2_GetFuncDesc(ti2, 3, &pfuncdesc);
2317 ok(hres == S_OK, "got %08x\n", hres);
2318
2319 ok(pfuncdesc->memid == 0x60010009, "got %x\n", pfuncdesc->memid);
2320 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2321 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2322 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2323 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2324 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2325 ok(pfuncdesc->cParams == 2, "got %d\n", pfuncdesc->cParams);
2326 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2327 ok(pfuncdesc->oVft == 6 * ptr_size, "got %d\n", pfuncdesc->oVft);
2328 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2329 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2330 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2331
2332 edesc = pfuncdesc->lprgelemdescParam;
2333 ok(edesc->tdesc.vt == VT_INT, "got: %d\n", edesc->tdesc.vt);
2334 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FIN, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2335 ok(U(*edesc).paramdesc.pparamdescex == NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2336
2337 edesc = pfuncdesc->lprgelemdescParam + 1;
2338 ok(edesc->tdesc.vt == VT_UI2, "got: %d\n", edesc->tdesc.vt);
2339 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2340 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2341 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
2342 U(*edesc).paramdesc.pparamdescex->cBytes);
2343 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_UI2, "got: %d\n",
2344 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2345 ok(V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0xFFFF, "got: 0x%x\n",
2346 V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2347
2348 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2349
2350 U(elemdesc[0]).paramdesc.wParamFlags = PARAMFLAG_FHASDEFAULT;
2351 U(elemdesc[0]).paramdesc.pparamdescex = &paramdescex;
2352 elemdesc[1].tdesc.vt = VT_INT;
2353 V_VT(&paramdescex.varDefaultValue) = VT_INT;
2354 V_INT(&paramdescex.varDefaultValue) = 0xffffffff;
2355 hres = ICreateTypeInfo_AddFuncDesc(createti, 3, &funcdesc);
2356 ok(hres == S_OK, "got %08x\n", hres);
2357
2358 elemdesc[0].tdesc.vt = VT_BSTR;
2359 elemdesc[1].tdesc.vt = VT_BSTR;
2360 V_VT(&paramdescex.varDefaultValue) = VT_BSTR;
2361 V_BSTR(&paramdescex.varDefaultValue) = SysAllocString(defaultW);
2362 hres = ICreateTypeInfo_AddFuncDesc(createti, 3, &funcdesc);
2363 ok(hres == S_OK, "got %08x\n", hres);
2364 SysFreeString(V_BSTR(&paramdescex.varDefaultValue));
2365
2366 WideCharToMultiByte(CP_ACP, 0, defaultW, -1, nameA, sizeof(nameA), NULL, NULL);
2368
2369 hres = ITypeInfo2_GetFuncDesc(ti2, 3, &pfuncdesc);
2370 ok(hres == S_OK, "got %08x\n", hres);
2371
2372 ok(pfuncdesc->memid == 0x6001000b, "got %x\n", pfuncdesc->memid);
2373 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2374 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2375 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2376 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2377 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2378 ok(pfuncdesc->cParams == 2, "got %d\n", pfuncdesc->cParams);
2379 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2380 ok(pfuncdesc->oVft == 6 * ptr_size, "got %d\n", pfuncdesc->oVft);
2381 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2382 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2383 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2384
2385 edesc = pfuncdesc->lprgelemdescParam;
2386 ok(edesc->tdesc.vt == VT_BSTR, "got: %d\n", edesc->tdesc.vt);
2387 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2388 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2389 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
2390 U(*edesc).paramdesc.pparamdescex->cBytes);
2391 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_BSTR, "got: %d\n",
2392 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2393 ok(!lstrcmpW(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue), nameW),
2394 "got: %s\n",
2395 wine_dbgstr_w(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue)));
2396
2397 edesc = pfuncdesc->lprgelemdescParam + 1;
2398 ok(edesc->tdesc.vt == VT_BSTR, "got: %d\n", edesc->tdesc.vt);
2399 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2400 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2401 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
2402 U(*edesc).paramdesc.pparamdescex->cBytes);
2403 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_BSTR, "got: %d\n",
2404 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2405 ok(!lstrcmpW(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue), nameW),
2406 "got: %s\n",
2407 wine_dbgstr_w(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue)));
2408
2409 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2410
2411 elemdesc[0].tdesc.vt = VT_USERDEFINED;
2412 U(elemdesc[0].tdesc).hreftype = hreftype;
2413 U(elemdesc[0]).paramdesc.pparamdescex = &paramdescex;
2414 U(elemdesc[0]).paramdesc.wParamFlags = PARAMFLAG_FHASDEFAULT;
2415 V_VT(&paramdescex.varDefaultValue) = VT_INT;
2416 V_INT(&paramdescex.varDefaultValue) = 0x789;
2417
2418 funcdesc.lprgelemdescParam = elemdesc;
2419 funcdesc.invkind = INVOKE_FUNC;
2420 funcdesc.cParams = 1;
2421 funcdesc.elemdescFunc.tdesc.vt = VT_VOID;
2422
2423 hres = ICreateTypeInfo_AddFuncDesc(createti, 5, &funcdesc);
2424 ok(hres == S_OK, "got %08x\n", hres);
2425
2426 hres = ITypeInfo2_GetFuncDesc(ti2, 5, &pfuncdesc);
2427 ok(hres == S_OK, "got %08x\n", hres);
2428
2429 ok(pfuncdesc->memid == 0x60010005, "got %x\n", pfuncdesc->memid);
2430 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2431 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2432 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2433 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2434 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2435 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2436 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2437 ok(pfuncdesc->oVft == 8 * ptr_size, "got %d\n", pfuncdesc->oVft);
2438 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2439 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2440 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2441
2442 edesc = pfuncdesc->lprgelemdescParam;
2443 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2444 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT,
2445 "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2446 ok(edesc->tdesc.vt == VT_USERDEFINED, "got: %d\n", edesc->tdesc.vt);
2447 ok(U(edesc->tdesc).hreftype == hreftype, "got: 0x%x\n", U(edesc->tdesc).hreftype);
2448 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_INT, "got: %d\n",
2449 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2450 ok(V_INT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0x789, "got: %d\n",
2451 V_INT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2452
2453 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2454
2455 elemdesc[0].tdesc.vt = VT_VARIANT;
2456 U(elemdesc[0]).paramdesc.pparamdescex = &paramdescex;
2457 U(elemdesc[0]).paramdesc.wParamFlags = PARAMFLAG_FHASDEFAULT;
2458 V_VT(&paramdescex.varDefaultValue) = VT_INT;
2459 V_INT(&paramdescex.varDefaultValue) = 3;
2460
2461 funcdesc.lprgelemdescParam = elemdesc;
2462 funcdesc.invkind = INVOKE_FUNC;
2463 funcdesc.cParams = 1;
2464 funcdesc.elemdescFunc.tdesc.vt = VT_VARIANT;
2465
2466 hres = ICreateTypeInfo_AddFuncDesc(createti, 6, &funcdesc);
2467 ok(hres == S_OK, "got %08x\n", hres);
2468
2469 hres = ITypeInfo2_GetFuncDesc(ti2, 6, &pfuncdesc);
2470 ok(hres == S_OK, "got %08x\n", hres);
2471
2472 ok(pfuncdesc->memid == 0x60010006, "got %x\n", pfuncdesc->memid);
2473 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2474 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2475 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2476 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2477 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2478 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2479 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2480 ok(pfuncdesc->oVft == 9 * ptr_size, "got %d\n", pfuncdesc->oVft);
2481 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2482 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VARIANT, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2483 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2484
2485 edesc = pfuncdesc->lprgelemdescParam;
2486 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2487 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT,
2488 "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2489 ok(edesc->tdesc.vt == VT_VARIANT, "got: %d\n", edesc->tdesc.vt);
2490 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_INT, "got: %d\n",
2491 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2492 ok(V_INT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 3, "got: %d\n",
2493 V_INT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2494
2495 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2496
2497 hres = ITypeInfo_GetDocumentation(interface1, 0, &name, &docstring, &helpcontext, &helpfile);
2498 ok(hres == S_OK, "got %08x\n", hres);
2499 ok(name == NULL, "name != NULL\n");
2500 ok(docstring == NULL, "docstring != NULL\n");
2501 ok(helpcontext == 0x201, "helpcontext != 0x201\n");
2502 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "helpfile = %s\n", wine_dbgstr_w(helpfile));
2503
2505
2506 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 1000, NULL, 1);
2507 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2508
2509 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 1000, names1, 1);
2510 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2511
2512 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, names1, 2);
2513 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2514
2515 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, names2, 1);
2516 ok(hres == S_OK, "got %08x\n", hres);
2517
2518 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, names1, 1);
2519 ok(hres == S_OK, "got %08x\n", hres);
2520
2521 hres = ITypeInfo_GetDocumentation(interface1, 0, &name, NULL, NULL, NULL);
2522 ok(hres == S_OK, "got %08x\n", hres);
2523 ok(!memcmp(name, func1W, sizeof(func1W)), "name = %s\n", wine_dbgstr_w(name));
2524
2526
2527 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 3, names2, 3);
2528 ok(hres == S_OK, "got %08x\n", hres);
2529
2530 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 3, names1, 3);
2531 ok(hres == TYPE_E_AMBIGUOUSNAME, "got %08x\n", hres);
2532
2533 ITypeInfo2_Release(ti2);
2534 ICreateTypeInfo_Release(createti);
2535
2536 hres = ICreateTypeLib2_CreateTypeInfo(createtl, interface1W, TKIND_INTERFACE, &createti);
2537 ok(hres == TYPE_E_NAMECONFLICT, "got %08x\n", hres);
2538
2539 hres = ICreateTypeLib2_CreateTypeInfo(createtl, interface2W, TKIND_INTERFACE, &createti);
2540 ok(hres == S_OK, "got %08x\n", hres);
2541
2542 hres = ICreateTypeInfo_SetGuid(createti, &interface2guid);
2543 ok(hres == S_OK, "got %08x\n", hres);
2544
2545 hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&interface2);
2546 ok(hres == S_OK, "got %08x\n", hres);
2547
2548 hres = ITypeInfo_GetRefTypeOfImplType(interface2, 0, &hreftype);
2549 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2550
2551 hres = ICreateTypeInfo_AddRefTypeInfo(createti, interface1, &hreftype);
2552 ok(hres == S_OK, "got %08x\n", hres);
2553
2554 hres = ITypeInfo_GetRefTypeInfo(interface2, 0, &ti);
2555 ok(hres == S_OK, "got %08x\n", hres);
2556 ok(ti == interface1, "Received and added interfaces are different\n");
2557
2558 ITypeInfo_Release(ti);
2559
2560 hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype);
2561 ok(hres == S_OK, "got %08x\n", hres);
2562
2563 hres = ITypeInfo_GetRefTypeOfImplType(interface2, 0, &hreftype);
2564 ok(hres == S_OK, "got %08x\n", hres);
2565 ok(hreftype == 2, "hreftype = %d\n", hreftype);
2566
2567 hres = ITypeInfo_GetRefTypeOfImplType(interface2, -1, &hreftype);
2568 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2569
2570 hres = ICreateTypeInfo_SetImplTypeFlags(createti, 0, IMPLTYPEFLAG_FDEFAULT);
2571 ok(hres == TYPE_E_BADMODULEKIND, "got %08x\n", hres);
2572
2573 hres = ITypeInfo_GetImplTypeFlags(interface2, 0, &impltypeflags);
2574 ok(hres == S_OK, "got %08x\n", hres);
2575 ok(impltypeflags == 0, "impltypeflags = %x\n", impltypeflags);
2576
2577 hres = ITypeInfo_GetImplTypeFlags(interface2, 1, &impltypeflags);
2578 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2579
2580 funcdesc.elemdescFunc.tdesc.vt = VT_VOID;
2581 funcdesc.oVft = 0xaaac;
2582 hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc);
2583 if(sys == SYS_WIN64){
2584 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2585 funcdesc.oVft = 0xaab0;
2586 hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc);
2587 }
2588 ok(hres == S_OK, "got %08x\n", hres);
2589 funcdesc.oVft = 0xaaa8;
2590 hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc);
2591 ok(hres == S_OK, "got %08x\n", hres);
2592
2593 hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&ti2);
2594 ok(hres == S_OK, "got %08x\n", hres);
2595
2596 hres = ITypeInfo2_GetFuncDesc(ti2, 0, &pfuncdesc);
2597 ok(hres == S_OK, "got %08x\n", hres);
2598
2599 ok(pfuncdesc->memid == 0x60020000, "got %x\n", pfuncdesc->memid);
2600 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2601 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2602 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2603 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2604 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2605 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2606 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2607 ok(pfuncdesc->oVft == (short)0xaaa8, "got %d\n", pfuncdesc->oVft);
2608 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2609 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2610 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2611
2612 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2613 ITypeInfo2_Release(ti2);
2614
2615 funcdesc.oVft = 0;
2616
2617 ICreateTypeInfo_Release(createti);
2618
2619 VariantInit(&cust_data);
2620
2621 hres = ICreateTypeLib2_CreateTypeInfo(createtl, interface3W, TKIND_INTERFACE, &createti);
2622 ok(hres == S_OK, "got %08x\n", hres);
2623
2624 hres = ICreateTypeInfo_QueryInterface(createti, &IID_ICreateTypeInfo2, (void**)&createti2);
2625 ok(hres == S_OK, "got %08x\n", hres);
2626
2627 hres = ICreateTypeInfo2_QueryInterface(createti2, &IID_ITypeInfo2, (void**)&ti2);
2628 ok(hres == S_OK, "got %08x\n", hres);
2629
2630 hres = ITypeInfo2_GetCustData(ti2, NULL, NULL);
2631 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2632
2633 hres = ITypeInfo2_GetCustData(ti2, &custguid, NULL);
2634 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2635
2636 hres = ITypeInfo2_GetCustData(ti2, &custguid, &cust_data);
2637 ok(hres == S_OK, "got %08x\n", hres);
2638
2639 hres = ICreateTypeInfo2_SetCustData(createti2, NULL, NULL);
2640 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2641
2642 hres = ICreateTypeInfo2_SetCustData(createti2, &custguid, NULL);
2643 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2644
2645 hres = ICreateTypeInfo2_SetCustData(createti2, &custguid, &cust_data);
2646 ok(hres == DISP_E_BADVARTYPE, "got %08x\n", hres);
2647
2648 V_VT(&cust_data) = VT_UI4;
2649 V_I4(&cust_data) = 0xdeadbeef;
2650
2651 hres = ICreateTypeInfo2_SetCustData(createti2, &custguid, &cust_data);
2652 ok(hres == S_OK, "got %08x\n", hres);
2653
2654 V_I4(&cust_data) = 0;
2655 V_VT(&cust_data) = VT_EMPTY;
2656
2657 hres = ITypeInfo2_GetCustData(ti2, &custguid, &cust_data);
2658 ok(hres == S_OK, "got %08x\n", hres);
2659
2660 ok(V_VT(&cust_data) == VT_UI4, "got %d\n", V_VT(&cust_data));
2661 ok(V_I4(&cust_data) == 0xdeadbeef, "got 0x%08x\n", V_I4(&cust_data));
2662
2663 V_VT(&cust_data) = VT_UI4;
2664 V_I4(&cust_data) = 12345678;
2665
2666 hres = ICreateTypeInfo2_SetCustData(createti2, &custguid, &cust_data);
2667 ok(hres == S_OK, "got %08x\n", hres);
2668
2669 V_I4(&cust_data) = 0;
2670 V_VT(&cust_data) = VT_EMPTY;
2671
2672 hres = ITypeInfo2_GetCustData(ti2, &custguid, &cust_data);
2673 ok(hres == S_OK, "got %08x\n", hres);
2674
2675 ok(V_VT(&cust_data) == VT_UI4, "got %d\n", V_VT(&cust_data));
2676 ok(V_I4(&cust_data) == 12345678, "got 0x%08x\n", V_I4(&cust_data));
2677
2678 V_VT(&cust_data) = VT_BSTR;
2679 V_BSTR(&cust_data) = SysAllocString(asdfW);
2680
2681 hres = ICreateTypeInfo2_SetCustData(createti2, &custguid, &cust_data);
2682 ok(hres == S_OK, "got %08x\n", hres);
2683
2684 SysFreeString(V_BSTR(&cust_data));
2685 V_I4(&cust_data) = 0;
2686 V_VT(&cust_data) = VT_EMPTY;
2687
2688 hres = ITypeInfo2_GetCustData(ti2, &custguid, &cust_data);
2689 ok(hres == S_OK, "got %08x\n", hres);
2690
2691 ok(V_VT(&cust_data) == VT_BSTR, "got %d\n", V_VT(&cust_data));
2692 ok(!lstrcmpW(V_BSTR(&cust_data), asdfW), "got %s\n", wine_dbgstr_w(V_BSTR(&cust_data)));
2693 SysFreeString(V_BSTR(&cust_data));
2694
2695 V_VT(&cust_data) = VT_UI4;
2696 V_UI4(&cust_data) = 17;
2697
2698 hres = ITypeInfo2_GetCustData(ti2, &bogusguid, &cust_data);
2699 ok(hres == S_OK, "got %08x\n", hres);
2700
2701 ok(V_VT(&cust_data) == VT_EMPTY, "got: %d\n", V_VT(&cust_data));
2702
2703 ITypeInfo2_Release(ti2);
2704 ICreateTypeInfo2_Release(createti2);
2705 ICreateTypeInfo_Release(createti);
2706
2707 hres = ICreateTypeLib2_CreateTypeInfo(createtl, coclassW, TKIND_COCLASS, &createti);
2708 ok(hres == S_OK, "got %08x\n", hres);
2709
2710 hres = ICreateTypeInfo_AddRefTypeInfo(createti, interface1, &hreftype);
2711 ok(hres == S_OK, "got %08x\n", hres);
2712
2713 hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype);
2714 ok(hres == S_OK, "got %08x\n", hres);
2715
2716 hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype);
2717 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2718
2719 hres = ICreateTypeInfo_AddRefTypeInfo(createti, unknown, &hreftype);
2720 ok(hres == S_OK, "got %08x\n", hres);
2721
2722 hres = ICreateTypeInfo_AddImplType(createti, 1, hreftype);
2723 ok(hres == S_OK, "got %08x\n", hres);
2724
2725 hres = ICreateTypeInfo_AddImplType(createti, 1, hreftype);
2726 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2727
2728 hres = ICreateTypeInfo_AddImplType(createti, 2, hreftype);
2729 ok(hres == S_OK, "got %08x\n", hres);
2730
2731 hres = ICreateTypeInfo_SetImplTypeFlags(createti, 0, IMPLTYPEFLAG_FDEFAULT);
2732 ok(hres == S_OK, "got %08x\n", hres);
2733
2734 hres = ICreateTypeInfo_SetImplTypeFlags(createti, 1, IMPLTYPEFLAG_FRESTRICTED);
2735 ok(hres == S_OK, "got %08x\n", hres);
2736
2737 hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&ti);
2738 ok(hres == S_OK, "got %08x\n", hres);
2739
2740 hres = ITypeInfo_GetImplTypeFlags(ti, 0, NULL);
2741 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2742
2743 hres = ITypeInfo_GetImplTypeFlags(ti, 0, &impltypeflags);
2744 ok(hres == S_OK, "got %08x\n", hres);
2745 ok(impltypeflags == IMPLTYPEFLAG_FDEFAULT, "impltypeflags = %x\n", impltypeflags);
2746
2747 hres = ITypeInfo_GetImplTypeFlags(ti, 1, &impltypeflags);
2748 ok(hres == S_OK, "got %08x\n", hres);
2749 ok(impltypeflags == IMPLTYPEFLAG_FRESTRICTED, "impltypeflags = %x\n", impltypeflags);
2750
2751 hres = ITypeInfo_GetImplTypeFlags(ti, 2, &impltypeflags);
2752 ok(hres == S_OK, "got %08x\n", hres);
2753 ok(impltypeflags == 0, "impltypeflags = %x\n", impltypeflags);
2754
2755 hres = ITypeInfo_GetRefTypeOfImplType(ti, 0, &hreftype);
2756 ok(hres == S_OK, "got %08x\n", hres);
2757 ok(hreftype == 0, "hreftype = %d\n", hreftype);
2758
2759 hres = ITypeInfo_GetRefTypeOfImplType(ti, 1, &hreftype);
2760 ok(hres == S_OK, "got %08x\n", hres);
2761 ok(hreftype == 1, "hreftype = %d\n", hreftype);
2762
2763 hres = ITypeInfo_GetRefTypeOfImplType(ti, 2, &hreftype);
2764 ok(hres == S_OK, "got %08x\n", hres);
2765 ok(hreftype == 1, "hreftype = %d\n", hreftype);
2766
2767 hres = ITypeInfo_GetRefTypeOfImplType(ti, -1, &hreftype);
2768 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2769
2770 ITypeInfo_Release(ti);
2771
2772 ICreateTypeInfo_Release(createti);
2773
2774 hres = ICreateTypeLib2_CreateTypeInfo(createtl, dualW, TKIND_INTERFACE, &createti);
2775 ok(hres == S_OK, "got %08x\n", hres);
2776
2777 hres = ICreateTypeInfo_SetTypeFlags(createti, TYPEFLAG_FDUAL);
2778 ok(hres == S_OK, "got %08x\n", hres);
2779
2780 hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc);
2781 ok(hres == S_OK, "got %08x\n", hres);
2782
2783 hres = ICreateTypeInfo_AddRefTypeInfo(createti, dispatch, &hreftype);
2784 ok(hres == S_OK, "got %08x\n", hres);
2785
2786 hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype);
2787 ok(hres == S_OK, "got %08x\n", hres);
2788
2789 hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&dual);
2790 ok(hres == S_OK, "got %08x\n", hres);
2791
2792 hres = ITypeInfo_GetTypeAttr(dual, &typeattr);
2793 ok(hres == S_OK, "got %08x\n", hres);
2794 ok(typeattr->cbSizeInstance == ptr_size, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2795 ok(typeattr->typekind == 3, "typekind = %d\n", typeattr->typekind);
2796 ok(typeattr->cFuncs == 1, "cFuncs = %d\n", typeattr->cFuncs);
2797 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2798 ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
2799 ok(typeattr->cbSizeVft == 8 * ptr_size, "cbSizeVft = %d\n", typeattr->cbSizeVft);
2800 ok(typeattr->cbAlignment == 4, "cbAlignment = %d\n", typeattr->cbAlignment);
2801 ok(typeattr->wTypeFlags == (TYPEFLAG_FDISPATCHABLE|TYPEFLAG_FDUAL), "wTypeFlags = %d\n", typeattr->wTypeFlags);
2802 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2803 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2804
2805 ITypeInfo_ReleaseTypeAttr(dual, typeattr);
2806
2807 hres = ITypeInfo_GetRefTypeOfImplType(dual, -1, &hreftype);
2808 ok(hres == S_OK, "got %08x\n", hres);
2809 ok(hreftype == -2, "got %08x\n", hreftype);
2810
2811 hres = ITypeInfo_GetRefTypeInfo(dual, -2, &ti);
2812 ok(hres == S_OK, "got %08x\n", hres);
2813
2814 hres = ITypeInfo_GetTypeAttr(ti, &typeattr);
2815 ok(hres == S_OK, "got %08x\n", hres);
2816 ok(typeattr->cbSizeInstance == ptr_size, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2817 ok(typeattr->typekind == 4, "typekind = %d\n", typeattr->typekind);
2818 ok(typeattr->cFuncs == 8, "cFuncs = %d\n", typeattr->cFuncs);
2819 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2820 ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
2821 ok(typeattr->cbSizeVft == 7 * sizeof(void *), "cbSizeVft = %d\n", typeattr->cbSizeVft);
2822 ok(typeattr->cbAlignment == 4, "cbAlignment = %d\n", typeattr->cbAlignment);
2823 ok(typeattr->wTypeFlags == (TYPEFLAG_FDISPATCHABLE|TYPEFLAG_FDUAL), "wTypeFlags = %d\n", typeattr->wTypeFlags);
2824 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2825 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2826
2827 ITypeInfo_ReleaseTypeAttr(ti, typeattr);
2828
2829 ITypeInfo_Release(ti);
2830
2831 hres = ICreateTypeInfo_SetTypeDescAlias(createti, &typedesc1);
2832 ok(hres == TYPE_E_BADMODULEKIND, "got %08x\n", hres);
2833
2834 ICreateTypeInfo_Release(createti);
2835
2836 hres = ITypeInfo_GetTypeAttr(interface1, &typeattr);
2837 ok(hres == S_OK, "got %08x\n", hres);
2838 ok(typeattr->cbSizeInstance == ptr_size, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2839 ok(typeattr->typekind == 3, "typekind = %d\n", typeattr->typekind);
2840 ok(typeattr->cFuncs == 13, "cFuncs = %d\n", typeattr->cFuncs);
2841 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2842 ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
2843 ok(typeattr->cbSizeVft == 16 * ptr_size, "cbSizeVft = %d\n", typeattr->cbSizeVft);
2844 ok(typeattr->cbAlignment == 4, "cbAlignment = %d\n", typeattr->cbAlignment);
2845 ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
2846 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2847 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2848
2849 ITypeInfo_ReleaseTypeAttr(interface1, typeattr);
2850
2851 hres = ITypeInfo_GetTypeAttr(interface2, &typeattr);
2852 ok(hres == S_OK, "got %08x\n", hres);
2853 ok(typeattr->cbSizeInstance == ptr_size, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2854 ok(typeattr->typekind == 3, "typekind = %d\n", typeattr->typekind);
2855 ok(typeattr->cFuncs == 2, "cFuncs = %d\n", typeattr->cFuncs);
2856 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2857 ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
2858 ok((sys == SYS_WIN32 && typeattr->cbSizeVft == 0xaab0) ||
2859 (sys == SYS_WIN64 && typeattr->cbSizeVft == 0xaab8),
2860 "cbSizeVft = 0x%x\n", typeattr->cbSizeVft);
2861 ok(typeattr->cbAlignment == 4, "cbAlignment = %d\n", typeattr->cbAlignment);
2862 ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
2863 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2864 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2865
2866 ITypeInfo_ReleaseTypeAttr(interface2, typeattr);
2867
2868 ok(ITypeInfo_Release(interface2)==0, "Object should be freed\n");
2869 ok(ITypeInfo_Release(interface1)==0, "Object should be freed\n");
2870 ok(ITypeInfo_Release(dual)==0, "Object should be freed\n");
2871
2872 hres = ICreateTypeLib2_CreateTypeInfo(createtl, aliasW, TKIND_ALIAS, &createti);
2873 ok(hres == S_OK, "got %08x\n", hres);
2874
2875 hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&interface1);
2876 ok(hres == S_OK, "got %08x\n", hres);
2877
2878 if(0){
2879 /* windows gives invalid values here, and even breaks the typeinfo permanently
2880 * on winxp. only call GetTypeAttr() on a TKIND_ALIAS after SetTypeDescAlias. */
2881 hres = ITypeInfo_GetTypeAttr(interface1, &typeattr);
2882 ok(hres == S_OK, "got %08x\n", hres);
2883 ok(typeattr->cbSizeInstance == 0xffffffb4, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2884 ok(typeattr->typekind == TKIND_ALIAS, "typekind = %d\n", typeattr->typekind);
2885 ok(typeattr->cFuncs == 0, "cFuncs = %d\n", typeattr->cFuncs);
2886 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2887 ok(typeattr->cImplTypes == 0, "cImplTypes = %d\n", typeattr->cImplTypes);
2888 ok(typeattr->cbSizeVft == 0, "cbSizeVft = %d\n", typeattr->cbSizeVft);
2889 ok(typeattr->cbAlignment == 0, "cbAlignment = %d\n", typeattr->cbAlignment);
2890 ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
2891 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2892 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2893 ok(typeattr->tdescAlias.vt == VT_EMPTY, "Got wrong tdescAlias.vt: %u\n", typeattr->tdescAlias.vt);
2894 ITypeInfo_ReleaseTypeAttr(interface1, typeattr);
2895 }
2896
2897 hres = ICreateTypeInfo_SetTypeDescAlias(createti, NULL);
2898 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2899
2900 typedesc1.vt = VT_I1;
2901 hres = ICreateTypeInfo_SetTypeDescAlias(createti, &typedesc1);
2902 ok(hres == S_OK, "got %08x\n", hres);
2903
2904 hres = ITypeInfo_GetTypeAttr(interface1, &typeattr);
2905 ok(hres == S_OK, "got %08x\n", hres);
2906 ok(typeattr->cbSizeInstance == 1, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2907 ok(typeattr->typekind == TKIND_ALIAS, "typekind = %d\n", typeattr->typekind);
2908 ok(typeattr->cFuncs == 0, "cFuncs = %d\n", typeattr->cFuncs);
2909 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2910 ok(typeattr->cImplTypes == 0, "cImplTypes = %d\n", typeattr->cImplTypes);
2911 ok(typeattr->cbSizeVft == 0, "cbSizeVft = %d\n", typeattr->cbSizeVft);
2912 ok(typeattr->cbAlignment == 1, "cbAlignment = %d\n", typeattr->cbAlignment);
2913 ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
2914 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2915 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2916 ok(typeattr->tdescAlias.vt == VT_I1, "Got wrong tdescAlias.vt: %u\n", typeattr->tdescAlias.vt);
2917 ITypeInfo_ReleaseTypeAttr(interface1, typeattr);
2918
2919 typedesc1.vt = VT_R8;
2920 hres = ICreateTypeInfo_SetTypeDescAlias(createti, &typedesc1);
2921 ok(hres == S_OK, "got %08x\n", hres);
2922
2923 hres = ITypeInfo_GetTypeAttr(interface1, &typeattr);
2924 ok(hres == S_OK, "got %08x\n", hres);
2925 ok(typeattr->cbSizeInstance == 8, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2926 ok(typeattr->typekind == TKIND_ALIAS, "typekind = %d\n", typeattr->typekind);
2927 ok(typeattr->cFuncs == 0, "cFuncs = %d\n", typeattr->cFuncs);
2928 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2929 ok(typeattr->cImplTypes == 0, "cImplTypes = %d\n", typeattr->cImplTypes);
2930 ok(typeattr->cbSizeVft == 0, "cbSizeVft = %d\n", typeattr->cbSizeVft);
2931 ok(typeattr->cbAlignment == 4, "cbAlignment = %d\n", typeattr->cbAlignment);
2932 ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
2933 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2934 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2935 ok(typeattr->tdescAlias.vt == VT_R8, "Got wrong tdescAlias.vt: %u\n", typeattr->tdescAlias.vt);
2936 ITypeInfo_ReleaseTypeAttr(interface1, typeattr);
2937
2938 ITypeInfo_Release(interface1);
2939 ICreateTypeInfo_Release(createti);
2940
2941 hres = ICreateTypeLib2_SaveAllChanges(createtl);
2942 ok(hres == S_OK, "got %08x\n", hres);
2943
2944 ok(ICreateTypeLib2_Release(createtl)==0, "Object should be freed\n");
2945
2946 ok(ITypeInfo_Release(dispatch)==0, "Object should be freed\n");
2947 ok(ITypeInfo_Release(unknown)==0, "Object should be freed\n");
2948 ok(ITypeLib_Release(stdole)==0, "Object should be freed\n");
2949
2951 ok(hres == S_OK, "got %08x\n", hres);
2952
2953 hres = ITypeLib_GetLibAttr(tl, &libattr);
2954 ok(hres == S_OK, "got %08x\n", hres);
2955 ok(libattr->syskind == sys, "syskind = %d\n", libattr->syskind);
2956 ok(libattr->wMajorVerNum == 0, "wMajorVer = %d\n", libattr->wMajorVerNum);
2957 ok(libattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", libattr->wMinorVerNum);
2958 ok(libattr->wLibFlags == LIBFLAG_FHASDISKIMAGE, "wLibFlags = %d\n", libattr->wLibFlags);
2959 ITypeLib_ReleaseTLibAttr(tl, libattr);
2960
2961 found = 2;
2962 memset(tinfos, 0, sizeof(tinfos));
2963 memids[0] = 0xdeadbeef;
2964 memids[1] = 0xdeadbeef;
2965 hres = ITypeLib_FindName(tl, param1W, 0, tinfos, memids, &found);
2966 ok(hres == S_OK, "got: %08x\n", hres);
2967 ok(found == 0, "got wrong count: %u\n", found);
2968 ok(tinfos[0] == NULL, "got invalid typeinfo[0]\n");
2969 ok(tinfos[1] == NULL, "got invalid typeinfo[1]\n");
2970 ok(memids[0] == 0xdeadbeef, "got invalid memid[0]\n");
2971 ok(memids[1] == 0xdeadbeef, "got invalid memid[1]\n");
2972
2973 found = 2;
2974 memset(tinfos, 0, sizeof(tinfos));
2975 memids[0] = 0xdeadbeef;
2976 memids[1] = 0xdeadbeef;
2977 hres = ITypeLib_FindName(tl, func1W, 0, tinfos, memids, &found);
2978 ok(hres == S_OK, "got: %08x\n", hres);
2979 ok(found == 1, "got wrong count: %u\n", found);
2980 ok(tinfos[0] != NULL, "got invalid typeinfo[0]\n");
2981 ok(tinfos[1] == NULL, "got invalid typeinfo[1]\n");
2982 ok(memids[0] == 0, "got invalid memid[0]\n");
2983 ok(memids[1] == 0xdeadbeef, "got invalid memid[1]\n");
2984 if(tinfos[0])
2985 ITypeInfo_Release(tinfos[0]);
2986
2987 found = 2;
2988 memset(tinfos, 0, sizeof(tinfos));
2989 memids[0] = 0xdeadbeef;
2990 memids[1] = 0xdeadbeef;
2991 hres = ITypeLib_FindName(tl, interface1W, 0, tinfos, memids, &found);
2992 ok(hres == S_OK, "got: %08x\n", hres);
2993 ok(found == 1, "got wrong count: %u\n", found);
2994 ok(tinfos[0] != NULL, "got invalid typeinfo[0]\n");
2995 ok(tinfos[1] == NULL, "got invalid typeinfo[1]\n");
2996 ok(memids[0] == MEMBERID_NIL, "got invalid memid[0]: %x\n", memids[0]);
2997 ok(memids[1] == 0xdeadbeef, "got invalid memid[1]\n");
2998 if(tinfos[0])
2999 ITypeInfo_Release(tinfos[0]);
3000
3001 hres = ITypeLib_GetDocumentation(tl, -1, &name, &docstring, &helpcontext, &helpfile);
3002 ok(hres == S_OK, "got %08x\n", hres);
3003 ok(memcmp(typelibW, name, sizeof(typelibW)) == 0, "got wrong typelib name: %s\n",
3005 ok(docstring == NULL, "got wrong docstring: %s\n", wine_dbgstr_w(docstring));
3006 ok(helpcontext == 0, "got wrong helpcontext: 0x%x\n", helpcontext);
3007 ok(memcmp(helpfileW, helpfile, sizeof(helpfileW)) == 0,
3008 "got wrong helpfile: %s\n", wine_dbgstr_w(helpfile));
3011
3012 hres = ITypeLib_GetDocumentation(tl, 0, &name, &docstring, &helpcontext, &helpfile);
3013 ok(hres == S_OK, "got %08x\n", hres);
3014 ok(memcmp(interface1W, name, sizeof(interface1W)) == 0, "got wrong typeinfo name: %s\n",
3016 ok(docstring == NULL, "got wrong docstring: %s\n", wine_dbgstr_w(docstring));
3017 ok(helpcontext == 0, "got wrong helpcontext: 0x%x\n", helpcontext);
3018 ok(memcmp(helpfileW, helpfile, sizeof(helpfileW)) == 0,
3019 "got wrong helpfile: %s\n", wine_dbgstr_w(helpfile));
3022
3023 hres = ITypeLib_QueryInterface(tl, &IID_ITypeLib2, (void**)&tl2);
3024 ok(hres == S_OK, "no ITypeLib2 interface (%x)\n", hres);
3025 V_VT(&cust_data) = VT_EMPTY;
3026 V_I4(&cust_data) = 0;
3027 hres = ITypeLib2_GetCustData(tl2, &tlcustguid, &cust_data);
3028 ok(hres == S_OK, "got %08x\n", hres);
3029 ok(V_VT(&cust_data) == VT_I4, "V_VT(&cust_data) = %d\n", V_VT(&cust_data));
3030 ok(V_I4(&cust_data) == 1, "V_I4(&cust_data) = %d\n", V_I4(&cust_data));
3031 ITypeLib2_Release(tl2);
3032
3033 hres = ITypeLib_GetTypeInfo(tl, 0, &ti);
3034 ok(hres == S_OK, "got %08x\n", hres);
3035
3036 hres = ITypeInfo_GetTypeAttr(ti, &typeattr);
3037 ok(hres == S_OK, "got %08x\n", hres);
3038 ok(typeattr->cbSizeInstance == sizeof(void*), "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
3039 ok(typeattr->typekind == TKIND_INTERFACE, "typekind = %d\n", typeattr->typekind);
3040 ok(typeattr->cFuncs == 13, "cFuncs = %d\n", typeattr->cFuncs);
3041 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
3042 ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
3044 ok(typeattr->cbSizeVft == 16 * sizeof(void*), "cbSizeVft = %d\n", typeattr->cbSizeVft);
3045 ok(typeattr->cbAlignment == alignment, "cbAlignment = %d\n", typeattr->cbAlignment);
3046 ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
3047 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
3048 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
3049 ITypeInfo_ReleaseTypeAttr(ti, typeattr);
3050
3051 hres = ITypeInfo_GetRefTypeOfImplType(ti, 0, &hreftype);
3052 ok(hres == S_OK, "got %08x\n", hres);
3053 ok(hreftype == 3, "hreftype = %d\n", hreftype);
3054
3055 hres = ITypeInfo_GetRefTypeInfo(ti, hreftype, &unknown);
3056 ok(hres == S_OK, "got %08x\n", hres);
3057
3058 hres = ITypeInfo_GetTypeAttr(unknown, &typeattr);
3059 ok(hres == S_OK, "got %08x\n", hres);
3060 ok(IsEqualGUID(&typeattr->guid, &IID_IUnknown), "got wrong reftypeinfo\n");
3061 ITypeInfo_ReleaseTypeAttr(unknown, typeattr);
3062
3063 ITypeInfo_Release(unknown);
3064
3065 hres = ITypeInfo_GetFuncDesc(ti, 0, &pfuncdesc);
3066 ok(hres == S_OK, "got %08x\n", hres);
3067 ok(pfuncdesc->memid == 0, "got %x\n", pfuncdesc->memid);
3068 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3069 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3070 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3071 ok(pfuncdesc->invkind == INVOKE_PROPERTYPUTREF, "got 0x%x\n", pfuncdesc->invkind);
3072 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3073 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
3074 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3075 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3076 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3077 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3078 edesc = pfuncdesc->lprgelemdescParam;
3079 ok(edesc->tdesc.vt == VT_BSTR, "got: %d\n", edesc->tdesc.vt);
3080 ok(U(*edesc).idldesc.wIDLFlags == IDLFLAG_FIN, "got: %x\n", U(*edesc).idldesc.wIDLFlags);
3081
3082 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3083 ok(hres == S_OK, "got: %08x\n", hres);
3084 ok(!memcmp(name, func1W, sizeof(func1W)), "got name: %s\n", wine_dbgstr_w(name));
3085 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3086 ok(helpcontext == 0x201, "got helpcontext: 0x%x\n", helpcontext);
3087 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3090
3091 hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, NULL, 0, &cnames);
3092 ok(hres == E_INVALIDARG, "got: %08x\n", hres);
3093
3094 cnames = 8;
3095 hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, 0, &cnames);
3096 ok(hres == S_OK, "got: %08x\n", hres);
3097 ok(cnames == 0, "got: %u\n", cnames);
3098
3099 hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, ARRAY_SIZE(names), &cnames);
3100 ok(hres == S_OK, "got: %08x\n", hres);
3101 ok(cnames == 1, "got: %u\n", cnames);
3102 ok(!memcmp(names[0], func1W, sizeof(func1W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
3103 SysFreeString(names[0]);
3104
3105 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3106
3107 hres = ITypeInfo_GetFuncDesc(ti, 1, &pfuncdesc);
3108 ok(hres == S_OK, "got %08x\n", hres);
3109 ok(pf