ReactOS  0.4.12-dev-418-g3df31a8
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 
79 static HRESULT (WINAPI *pRegisterTypeLibForUser)(ITypeLib*,OLECHAR*,OLECHAR*);
80 static HRESULT (WINAPI *pUnRegisterTypeLibForUser)(REFGUID,WORD,WORD,LCID,SYSKIND);
81 
82 static BOOL (WINAPI *pActivateActCtx)(HANDLE,ULONG_PTR*);
83 static HANDLE (WINAPI *pCreateActCtxW)(PCACTCTXW);
84 static BOOL (WINAPI *pDeactivateActCtx)(DWORD,ULONG_PTR);
85 static VOID (WINAPI *pReleaseActCtx)(HANDLE);
86 static BOOL (WINAPI *pIsWow64Process)(HANDLE,LPBOOL);
87 static LONG (WINAPI *pRegDeleteKeyExW)(HKEY,LPCWSTR,REGSAM,DWORD);
88 
89 static const WCHAR wszStdOle2[] = {'s','t','d','o','l','e','2','.','t','l','b',0};
90 static WCHAR wszGUID[] = {'G','U','I','D',0};
91 static WCHAR wszguid[] = {'g','u','i','d',0};
92 
93 static const BOOL is_win64 = sizeof(void *) > sizeof(int);
94 
95 #ifdef __i386__
96 static const BOOL abi_supports_stdcall = TRUE;
97 #else
99 #endif
100 
101 static HRESULT WINAPI collection_QueryInterface(ICollection *iface, REFIID riid, void **ret)
102 {
103  if (IsEqualIID(riid, &IID_IUnknown) ||
105  IsEqualIID(riid, &IID_ICollection))
106  {
107  *ret = iface;
108  return S_OK;
109  }
110 
111  return E_NOINTERFACE;
112 }
113 
114 static ULONG WINAPI collection_AddRef(ICollection *iface)
115 {
116  return 2;
117 }
118 
119 static ULONG WINAPI collection_Release(ICollection *iface)
120 {
121  return 1;
122 }
123 
124 static HRESULT WINAPI collection_GetTypeInfoCount(ICollection *iface, UINT *cnt)
125 {
126  ok(0, "unexpected call\n");
127  *cnt = 0;
128  return E_NOTIMPL;
129 }
130 
131 static 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 
144 static 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 
167 static HRESULT WINAPI collection_Item(ICollection *iface, int i, int *p)
168 {
169  ok(0, "unexpected call\n");
170  return E_NOTIMPL;
171 }
172 
173 static const ICollectionVtbl collectionvtbl = {
182 };
183 
184 static ICollection collection = { &collectionvtbl };
185 
186 static HRESULT WINAPI invoketest_QueryInterface(IInvokeTest *iface, REFIID riid, void **ret)
187 {
188  if (IsEqualIID(riid, &IID_IUnknown) ||
190  IsEqualIID(riid, &IID_IInvokeTest))
191  {
192  *ret = iface;
193  return S_OK;
194  }
195 
196  return E_NOINTERFACE;
197 }
198 
199 static ULONG WINAPI invoketest_AddRef(IInvokeTest *iface)
200 {
201  return 2;
202 }
203 
204 static ULONG WINAPI invoketest_Release(IInvokeTest *iface)
205 {
206  return 1;
207 }
208 
209 static HRESULT WINAPI invoketest_GetTypeInfoCount(IInvokeTest *iface, UINT *cnt)
210 {
211  ok(0, "unexpected call\n");
212  *cnt = 0;
213  return E_NOTIMPL;
214 }
215 
216 static 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 
229 static 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 
236 static LONG WINAPI invoketest_get_test(IInvokeTest *iface, LONG i)
237 {
238  return i+1;
239 }
240 
241 static LONG WINAPI invoketest_putref_testprop(IInvokeTest *iface, LONG *i)
242 {
243  return *i+2;
244 }
245 
246 static LONG WINAPI invoketest_putref_testprop2(IInvokeTest *iface, IUnknown *i)
247 {
248  return 6;
249 }
250 
251 static HRESULT WINAPI invoketest_testfunc(IInvokeTest *iface, int i, int *p)
252 {
253  *p = i+1;
254  return S_OK;
255 }
256 
257 static HRESULT WINAPI invoketest_testget(IInvokeTest *iface, ICollection **p)
258 {
259  *p = &collection;
260  ICollection_AddRef(&collection);
261  return S_OK;
262 }
263 
264 static const IInvokeTestVtbl invoketestvtbl = {
277 };
278 
279 static IInvokeTest invoketest = { &invoketestvtbl };
280 
281 static 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 
297 static 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 
327 static 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);
393  ok(hr == TYPE_E_TYPEMISMATCH,
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 
609 static 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 = sizeof(methdata) / sizeof(methdata[0]);
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 
769 static 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;
793  HRESULT hres;
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 
803  V_VT(args) = VT_DISPATCH;
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 
814 static 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 
823 static 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);
876  ok(hr == DISP_E_UNKNOWNNAME,
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  {
953  VariantInit(&var);
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 
964  VariantClear(&var);
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 
1129 static 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 
1139 static double WINAPI double_func( double a0, float a1, double a2, int a3 )
1140 {
1141  ok( a0 == 1.2, "wrong arg0 %f\n", (double)a0 );
1142  ok( a1 == 3.25, "wrong arg1 %f\n", (double)a1 );
1143  ok( a2 == 1.2e12, "wrong arg2 %f\n", (double)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 
1170 static 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 
1185 static int WINAPI stdcall_func( int a )
1186 {
1187  return 0;
1188 }
1189 
1190 static 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 
1202 static 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 
1215 static 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 
1231 static void *vtable[] = { NULL, NULL, NULL, inst_func };
1232 static void *vtable2[] = { NULL, NULL, NULL, inst_func2 };
1233 
1234 static 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;
1252  V_BSTR(&args[1]) = SysAllocString(testW);
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 */
1386 static LSTATUS myRegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey, REGSAM view)
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 > sizeof(szNameBuf)/sizeof(WCHAR))
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 
1445 cleanup:
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 < sizeof(td)/sizeof(td[0]); 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 
1555 static 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;
1563  WCHAR path[MAX_PATH];
1564  CHAR pathA[MAX_PATH];
1565  static const WCHAR tl_path[] = {'.','\\','m','i','d','l','_','t','m','a','r','s','h','a','l','.','t','l','b',0};
1566 
1567  BOOL use_midl_tlb = FALSE;
1568 
1571 
1572  if(use_midl_tlb)
1573  memcpy(path, tl_path, sizeof(tl_path));
1574 
1575  hr = LoadTypeLib(path, &pTL);
1576  if(FAILED(hr)) return;
1577 
1578 
1579  /* ItestIF3 is a syntax 2 dispinterface */
1580  hr = ITypeLib_GetTypeInfoOfGuid(pTL, &DIID_ItestIF3, &pTI);
1581  ok(hr == S_OK, "hr %08x\n", hr);
1582 
1583  hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1584  ok(hr == S_OK, "hr %08x\n", hr);
1585  ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
1586  ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1587  ok(pTA->wTypeFlags == TYPEFLAG_FDISPATCHABLE, "typeflags %x\n", pTA->wTypeFlags);
1588 if(use_midl_tlb) {
1589  ok(pTA->cFuncs == 6, "cfuncs %d\n", pTA->cFuncs);
1590  ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1591 }
1592  ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1593 
1594 if(use_midl_tlb) {
1595  hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
1596  ok(hr == S_OK, "hr %08x\n", hr);
1597  hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1598  ok(hr == S_OK, "hr %08x\n", hr);
1599  hr = ITypeInfo_GetTypeAttr(pTI_p, &pTA);
1600  ok(hr == S_OK, "got %08x\n", hr);
1601  ok(IsEqualGUID(&pTA->guid, &IID_IDispatch), "guid {%08x-....\n", pTA->guid.Data1);
1602  ITypeInfo_ReleaseTypeAttr(pTI_p, pTA);
1603  ITypeInfo_Release(pTI_p);
1604 
1605  /* Should have six methods */
1606  hr = ITypeInfo_GetFuncDesc(pTI, 6, &pFD);
1607  ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
1608  hr = ITypeInfo_GetFuncDesc(pTI, 5, &pFD);
1609  ok(hr == S_OK, "hr %08x\n", hr);
1610  ok(pFD->memid == 0x60020000, "memid %08x\n", pFD->memid);
1611  ok(pFD->oVft == 5 * sizeof(void *), "oVft %d\n", pFD->oVft);
1612  ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1613 }
1614  ITypeInfo_Release(pTI);
1615 
1616 
1617  /* ItestIF4 is a syntax 1 dispinterface */
1618  hr = ITypeLib_GetTypeInfoOfGuid(pTL, &DIID_ItestIF4, &pTI);
1619  ok(hr == S_OK, "hr %08x\n", hr);
1620 
1621  hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1622  ok(hr == S_OK, "hr %08x\n", hr);
1623  ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
1624  ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1625  ok(pTA->wTypeFlags == TYPEFLAG_FDISPATCHABLE, "typeflags %x\n", pTA->wTypeFlags);
1626  ok(pTA->cFuncs == 1, "cfuncs %d\n", pTA->cFuncs);
1627  ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1628  ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1629 
1630  hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
1631  ok(hr == S_OK, "hr %08x\n", hr);
1632  hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1633  ok(hr == S_OK, "hr %08x\n", hr);
1634  hr = ITypeInfo_GetTypeAttr(pTI_p, &pTA);
1635  ok(hr == S_OK, "got %08x\n", hr);
1636  ok(IsEqualGUID(&pTA->guid, &IID_IDispatch), "guid {%08x-....\n", pTA->guid.Data1);
1637  ITypeInfo_ReleaseTypeAttr(pTI_p, pTA);
1638  ITypeInfo_Release(pTI_p);
1639  hr = ITypeInfo_GetFuncDesc(pTI, 1, &pFD);
1640  ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
1641  hr = ITypeInfo_GetFuncDesc(pTI, 0, &pFD);
1642  ok(hr == S_OK, "hr %08x\n", hr);
1643  ok(pFD->memid == 0x1c, "memid %08x\n", pFD->memid);
1644  ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1645  ITypeInfo_Release(pTI);
1646 
1647 
1648  /* ItestIF5 is dual with inherited ifaces which derive from IUnknown but not IDispatch */
1649  hr = ITypeLib_GetTypeInfoOfGuid(pTL, &IID_ItestIF5, &pTI);
1650  ok(hr == S_OK, "hr %08x\n", hr);
1651 
1652  hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1653  ok(hr == S_OK, "hr %08x\n", hr);
1654  if (hr == S_OK)
1655  {
1656  ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
1657  ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1658  if(use_midl_tlb) {
1659  ok(pTA->wTypeFlags == TYPEFLAG_FDUAL, "typeflags %x\n", pTA->wTypeFlags);
1660  }
1661  ok(pTA->cFuncs == 8, "cfuncs %d\n", pTA->cFuncs);
1662  ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1663  ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1664  }
1665  hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
1666  ok(hr == S_OK, "hr %08x\n", hr);
1667  hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1668  ok(hr == S_OK, "hr %08x\n", hr);
1669  hr = ITypeInfo_GetTypeAttr(pTI_p, &pTA);
1670  ok(hr == S_OK, "got %08x\n", hr);
1671  ok(IsEqualGUID(&pTA->guid, &IID_IDispatch), "guid {%08x-....\n", pTA->guid.Data1);
1672  ITypeInfo_ReleaseTypeAttr(pTI_p, pTA);
1673  ITypeInfo_Release(pTI_p);
1674 if(use_midl_tlb) {
1675  hr = ITypeInfo_GetFuncDesc(pTI, 6, &pFD);
1676  ok(hr == S_OK, "hr %08x\n", hr);
1677  ok(pFD->memid == 0x1234, "memid %08x\n", pFD->memid);
1678  ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1679 }
1680  ITypeInfo_Release(pTI);
1681 
1682  /* ItestIF7 is dual with inherited ifaces which derive from Dispatch */
1683  hr = ITypeLib_GetTypeInfoOfGuid(pTL, &IID_ItestIF7, &pTI);
1684  ok(hr == S_OK, "hr %08x\n", hr);
1685 
1686  hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1687  ok(hr == S_OK, "hr %08x\n", hr);
1688  ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
1689  ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1690  ok(pTA->wTypeFlags == (TYPEFLAG_FDISPATCHABLE|TYPEFLAG_FDUAL), "typeflags %x\n", pTA->wTypeFlags);
1691  ok(pTA->cFuncs == 10, "cfuncs %d\n", pTA->cFuncs);
1692  ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1693  ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1694 
1695  hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
1696  ok(hr == S_OK, "hr %08x\n", hr);
1697  hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1698  ok(hr == S_OK, "hr %08x\n", hr);
1699  hr = ITypeInfo_GetTypeAttr(pTI_p, &pTA);
1700  ok(hr == S_OK, "got %08x\n", hr);
1701  ok(IsEqualGUID(&pTA->guid, &IID_IDispatch), "guid {%08x-....\n", pTA->guid.Data1);
1702  ITypeInfo_ReleaseTypeAttr(pTI_p, pTA);
1703  ITypeInfo_Release(pTI_p);
1704 
1705  hr = ITypeInfo_GetFuncDesc(pTI, 9, &pFD);
1706  ok(hr == S_OK, "hr %08x\n", hr);
1707  ok(pFD->memid == 0x1236, "memid %08x\n", pFD->memid);
1708  ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1709  ITypeInfo_Release(pTI);
1710 
1711  /* ItestIF10 is a syntax 2 dispinterface which doesn't derive from IUnknown */
1712  hr = ITypeLib_GetTypeInfoOfGuid(pTL, &DIID_ItestIF10, &pTI);
1713  ok(hr == S_OK, "hr %08x\n", hr);
1714 
1715  hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1716  ok(hr == S_OK, "hr %08x\n", hr);
1717  ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
1718  ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1719  ok(pTA->wTypeFlags == TYPEFLAG_FDISPATCHABLE, "typeflags %x\n", pTA->wTypeFlags);
1720 if(use_midl_tlb) {
1721  ok(pTA->cFuncs == 3, "cfuncs %d\n", pTA->cFuncs);
1722  ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1723 }
1724  ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1725 
1726 if(use_midl_tlb) {
1727  hr = ITypeInfo_GetRefTypeOfImplType(pTI, -1, &href);
1728  ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
1729  hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
1730  ok(hr == S_OK, "hr %08x\n", hr);
1731  hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1732  ok(hr == S_OK, "hr %08x\n", hr);
1733  hr = ITypeInfo_GetTypeAttr(pTI_p, &pTA);
1734  ok(hr == S_OK, "got %08x\n", hr);
1735  ok(IsEqualGUID(&pTA->guid, &IID_IDispatch), "guid {%08x-....\n", pTA->guid.Data1);
1736  ITypeInfo_ReleaseTypeAttr(pTI_p, pTA);
1737  ITypeInfo_Release(pTI_p);
1738 
1739  /* Should have three methods */
1740  hr = ITypeInfo_GetFuncDesc(pTI, 3, &pFD);
1741  ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
1742  hr = ITypeInfo_GetFuncDesc(pTI, 2, &pFD);
1743  ok(hr == S_OK, "hr %08x\n", hr);
1744  ok(pFD->memid == 0x60010000, "memid %08x\n", pFD->memid);
1745  ok(pFD->oVft == 2 * sizeof(void *), "oVft %d\n", pFD->oVft);
1746  ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1747 }
1748  ITypeInfo_Release(pTI);
1749 
1750  /* ItestIF11 is a syntax 2 dispinterface which derives from IDispatch */
1751  hr = ITypeLib_GetTypeInfoOfGuid(pTL, &DIID_ItestIF11, &pTI);
1752  ok(hr == S_OK, "hr %08x\n", hr);
1753 
1754  hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1755  ok(hr == S_OK, "hr %08x\n", hr);
1756  ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
1757  ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1758  ok(pTA->wTypeFlags == TYPEFLAG_FDISPATCHABLE, "typeflags %x\n", pTA->wTypeFlags);
1759 if(use_midl_tlb) {
1760  ok(pTA->cFuncs == 10, "cfuncs %d\n", pTA->cFuncs);
1761  ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1762 }
1763  ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1764 
1765 if(use_midl_tlb) {
1766  hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
1767  ok(hr == S_OK, "hr %08x\n", hr);
1768  hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1769  ok(hr == S_OK, "hr %08x\n", hr);
1770  hr = ITypeInfo_GetTypeAttr(pTI_p, &pTA);
1771  ok(hr == S_OK, "got %08x\n", hr);
1772  ok(IsEqualGUID(&pTA->guid, &IID_IDispatch), "guid {%08x-....\n", pTA->guid.Data1);
1773  ITypeInfo_ReleaseTypeAttr(pTI_p, pTA);
1774  ITypeInfo_Release(pTI_p);
1775 
1776  /* Should have ten methods */
1777  hr = ITypeInfo_GetFuncDesc(pTI, 10, &pFD);
1778  ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
1779  hr = ITypeInfo_GetFuncDesc(pTI, 9, &pFD);
1780  ok(hr == S_OK, "hr %08x\n", hr);
1781  ok(pFD->memid == 0x1236, "memid %08x\n", pFD->memid);
1782  ok(pFD->oVft == 9 * sizeof(void *), "oVft %d\n", pFD->oVft);
1783 
1784  /* first argument to 10th function is an HREFTYPE from the impl type */
1785  ok(pFD->cParams == 1, "cParams %i\n", pFD->cParams);
1786  ok(pFD->lprgelemdescParam[0].tdesc.vt == VT_USERDEFINED,
1787  "vt 0x%x\n", pFD->lprgelemdescParam[0].tdesc.vt);
1788  href = U(pFD->lprgelemdescParam[0].tdesc).hreftype;
1789  ok((href & 0xff000000) == 0x04000000, "href 0x%08x\n", href);
1790  hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1791  ok(hr == S_OK, "hr %08x\n", hr);
1792  if (SUCCEEDED(hr)) ITypeInfo_Release(pTI_p);
1793  ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1794 }
1795  ITypeInfo_Release(pTI);
1796 
1797 
1798  /* ItestIF2 is an interface which derives from IUnknown */
1799  hr = ITypeLib_GetTypeInfoOfGuid(pTL, &IID_ItestIF2, &pTI);
1800  ok(hr == S_OK, "hr %08x\n", hr);
1801 
1802  hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1803  ok(hr == S_OK, "hr %08x\n", hr);
1804  ok(pTA->typekind == TKIND_INTERFACE, "kind %04x\n", pTA->typekind);
1805  ok(pTA->cbSizeVft == 6 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1806  ok(pTA->wTypeFlags == 0, "typeflags %x\n", pTA->wTypeFlags);
1807 if(use_midl_tlb) {
1808  ok(pTA->cFuncs == 1, "cfuncs %d\n", pTA->cFuncs);
1809  ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1810 }
1811  ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1812 
1813 if(use_midl_tlb) {
1814  /* Should have one method */
1815  hr = ITypeInfo_GetFuncDesc(pTI, 1, &pFD);
1816  ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
1817  hr = ITypeInfo_GetFuncDesc(pTI, 0, &pFD);
1818  ok(hr == S_OK, "hr %08x\n", hr);
1819  ok(pFD->memid == 0x60020000, "memid %08x\n", pFD->memid);
1820  ok(pFD->oVft == 5 * sizeof(void *), "oVft %d\n", pFD->oVft);
1821  ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1822 }
1823  ITypeInfo_Release(pTI);
1824 
1825  ITypeLib_Release(pTL);
1826 
1827  return;
1828 }
1829 
1830 static void test_CreateTypeLib(SYSKIND sys) {
1831  static OLECHAR typelibW[] = {'t','y','p','e','l','i','b',0};
1832  static OLECHAR helpfileW[] = {'C',':','\\','b','o','g','u','s','.','h','l','p',0};
1833  static OLECHAR interface1W[] = {'i','n','t','e','r','f','a','c','e','1',0};
1834  static OLECHAR interface2W[] = {'i','n','t','e','r','f','a','c','e','2',0};
1835  static OLECHAR interface3W[] = {'i','n','t','e','r','f','a','c','e','3',0};
1836  static OLECHAR dualW[] = {'d','u','a','l',0};
1837  static OLECHAR coclassW[] = {'c','o','c','l','a','s','s',0};
1838  static const WCHAR defaultW[] = {'d','e','f','a','u','l','t',0x3213,0};
1839  static OLECHAR func1W[] = {'f','u','n','c','1',0};
1840  static OLECHAR func2W[] = {'f','u','n','c','2',0};
1841  static OLECHAR prop1W[] = {'P','r','o','p','1',0};
1842  static OLECHAR param1W[] = {'p','a','r','a','m','1',0};
1843  static OLECHAR param2W[] = {'p','a','r','a','m','2',0};
1844  static OLECHAR asdfW[] = {'A','s','d','f',0};
1845  static OLECHAR aliasW[] = {'a','l','i','a','s',0};
1846  static OLECHAR invokeW[] = {'I','n','v','o','k','e',0};
1847  static OLECHAR *names1[] = {func1W, param1W, param2W};
1848  static OLECHAR *names2[] = {func2W, param1W, param2W};
1849  static OLECHAR *propname[] = {prop1W, param1W};
1850  static const GUID tlcustguid = {0xbf611abe,0x5b38,0x11df,{0x91,0x5c,0x08,0x02,0x79,0x79,0x94,0x69}};
1851  static const GUID custguid = {0xbf611abe,0x5b38,0x11df,{0x91,0x5c,0x08,0x02,0x79,0x79,0x94,0x70}};
1852  static const GUID bogusguid = {0xbf611abe,0x5b38,0x11df,{0x91,0x5c,0x08,0x02,0x79,0x79,0x94,0x71}};
1853  static const GUID interfaceguid = {0x3b9ff02f,0x9675,0x4861,{0xb7,0x81,0xce,0xae,0xa4,0x78,0x2a,0xcc}};
1854  static const GUID interface2guid = {0x3b9ff02f,0x9675,0x4861,{0xb7,0x81,0xce,0xae,0xa4,0x78,0x2a,0xcd}};
1855 
1856  char filename[MAX_PATH];
1858  ICreateTypeLib2 *createtl;
1859  ICreateTypeInfo *createti;
1860  ICreateTypeInfo2 *createti2;
1861  ITypeLib *tl, *stdole;
1862  ITypeLib2 *tl2;
1863  ITypeInfo *interface1, *interface2, *dual, *unknown, *dispatch, *ti;
1864  ITypeInfo *tinfos[2];
1865  ITypeInfo2 *ti2;
1866  ITypeComp *tcomp, *tcomp2;
1867  MEMBERID memids[2];
1868  FUNCDESC funcdesc, *pfuncdesc;
1869  ELEMDESC elemdesc[5], *edesc;
1870  PARAMDESCEX paramdescex;
1871  TYPEDESC typedesc1, typedesc2;
1872  TYPEATTR *typeattr;
1873  TLIBATTR *libattr;
1874  HREFTYPE hreftype;
1875  BSTR name, docstring, helpfile, names[3];
1876  DWORD helpcontext, ptr_size, alignment;
1877  int impltypeflags;
1878  unsigned int cnames;
1879  USHORT found;
1880  VARIANT cust_data;
1881  HRESULT hres;
1882  TYPEKIND kind;
1883  DESCKIND desckind;
1884  BINDPTR bindptr;
1885  char nameA[16];
1886  WCHAR nameW[16];
1887 
1888  switch(sys){
1889  case SYS_WIN32:
1890  trace("testing SYS_WIN32\n");
1891  ptr_size = 4;
1892  alignment = sizeof(void*);
1893  break;
1894  case SYS_WIN64:
1895  trace("testing SYS_WIN64\n");
1896  ptr_size = 8;
1897  alignment = 4;
1898  break;
1899  default:
1900  return;
1901  }
1902 
1903  trace("CreateTypeLib tests\n");
1904 
1906  ok(hres == S_OK, "got %08x\n", hres);
1907 
1908  hres = ITypeLib_GetTypeInfoOfGuid(stdole, &IID_IUnknown, &unknown);
1909  ok(hres == S_OK, "got %08x\n", hres);
1910 
1911  hres = ITypeInfo_GetTypeAttr(unknown, &typeattr);
1912  ok(hres == S_OK, "got %08x\n", hres);
1913  ok(typeattr->cbSizeVft == 3 * sizeof(void*), "Got wrong cbSizeVft: %u\n", typeattr->cbSizeVft);
1914  ITypeInfo_ReleaseTypeAttr(unknown, typeattr);
1915 
1916  hres = ITypeLib_GetTypeInfoOfGuid(stdole, &IID_IDispatch, &dispatch);
1917  ok(hres == S_OK, "got %08x\n", hres);
1918 
1919  GetTempFileNameA(".", "tlb", 0, filename);
1921 
1922  hres = CreateTypeLib2(sys, filenameW, &createtl);
1923  ok(hres == S_OK, "got %08x\n", hres);
1924 
1925  hres = ICreateTypeLib2_QueryInterface(createtl, &IID_ITypeLib, (void**)&tl);
1926  ok(hres == S_OK, "got %08x\n", hres);
1927 
1928  hres = ITypeLib_GetTypeInfo(tl, 0, NULL);
1929  ok(hres == E_INVALIDARG, "got 0x%08x\n", hres);
1930 
1931  hres = ITypeLib_GetTypeInfoType(tl, 0, &kind);
1932  ok(hres == TYPE_E_ELEMENTNOTFOUND, "got 0x%08x\n", hres);
1933 
1934  hres = ITypeLib_GetTypeInfoType(tl, 0, NULL);
1935  ok(hres == E_INVALIDARG, "got 0x%08x\n", hres);
1936 
1937  hres = ITypeLib_GetTypeInfoType(tl, 0, NULL);
1938  ok(hres == E_INVALIDARG, "got 0x%08x\n", hres);
1939 
1940  hres = ITypeLib_GetLibAttr(tl, NULL);
1941  ok(hres == E_INVALIDARG, "got %08x\n", hres);
1942 
1943  hres = ITypeLib_GetLibAttr(tl, &libattr);
1944  ok(hres == S_OK, "got %08x\n", hres);
1945 
1946  ok(libattr->syskind == sys, "syskind = %d\n", libattr->syskind);
1947  ok(libattr->wMajorVerNum == 0, "wMajorVer = %d\n", libattr->wMajorVerNum);
1948  ok(libattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", libattr->wMinorVerNum);
1949  ok(libattr->wLibFlags == 0, "wLibFlags = %d\n", libattr->wLibFlags);
1950 
1951  ITypeLib_ReleaseTLibAttr(tl, libattr);
1952 
1953  name = (BSTR)0xdeadbeef;
1954  hres = ITypeLib_GetDocumentation(tl, -1, &name, &docstring, &helpcontext, &helpfile);
1955  ok(hres == S_OK, "got %08x\n", hres);
1956  ok(name == NULL, "name != NULL\n");
1957  ok(docstring == NULL, "docstring != NULL\n");
1958  ok(helpcontext == 0, "helpcontext != 0\n");
1959  ok(helpfile == NULL, "helpfile != NULL\n");
1960 
1961  hres = ITypeLib_GetDocumentation(tl, 0, &name, NULL, NULL, NULL);
1962  ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
1963 
1964  hres = ICreateTypeLib2_SetName(createtl, typelibW);
1965  ok(hres == S_OK, "got %08x\n", hres);
1966 
1967  hres = ICreateTypeLib2_SetHelpFileName(createtl, helpfileW);
1968  ok(hres == S_OK, "got %08x\n", hres);
1969 
1970  hres = ITypeLib_GetDocumentation(tl, -1, NULL, NULL, NULL, NULL);
1971  ok(hres == S_OK, "got %08x\n", hres);
1972 
1973  hres = ITypeLib_GetDocumentation(tl, -1, &name, NULL, NULL, &helpfile);
1974  ok(hres == S_OK, "got %08x\n", hres);
1975  ok(!memcmp(name, typelibW, sizeof(typelibW)), "name = %s\n", wine_dbgstr_w(name));
1976  ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "helpfile = %s\n", wine_dbgstr_w(helpfile));
1977 
1980 
1981  V_VT(&cust_data) = VT_I4;
1982  V_I4(&cust_data) = 1;
1983  hres = ICreateTypeLib2_SetCustData(createtl, &tlcustguid, &cust_data);
1984  ok(hres == S_OK, "got %08x\n", hres);
1985 
1986  hres = ITypeLib_QueryInterface(tl, &IID_ITypeLib2, (void**)&tl2);
1987  ok(hres == S_OK, "no ITypeLib2 interface (%x)\n", hres);
1988 
1989  V_VT(&cust_data) = VT_EMPTY;
1990  V_I4(&cust_data) = 0;
1991  hres = ITypeLib2_GetCustData(tl2, &tlcustguid, &cust_data);
1992  ok(hres == S_OK, "got %08x\n", hres);
1993  ok(V_VT(&cust_data) == VT_I4, "V_VT(&cust_data) = %d\n", V_VT(&cust_data));
1994  ok(V_I4(&cust_data) == 1, "V_I4(&cust_data) = %d\n", V_I4(&cust_data));
1995 
1996  ITypeLib2_Release(tl2);
1997 
1998  /* invalid parameters */
1999  hres = ICreateTypeLib2_CreateTypeInfo(createtl, NULL, TKIND_INTERFACE, &createti);
2000  ok(hres == E_INVALIDARG, "got %08x\n", hres);
2001 
2002  hres = ICreateTypeLib2_CreateTypeInfo(createtl, interface1W, TKIND_INTERFACE, NULL);
2003  ok(hres == E_INVALIDARG, "got %08x\n", hres);
2004 
2005  hres = ICreateTypeLib2_CreateTypeInfo(createtl, NULL, TKIND_INTERFACE, NULL);
2006  ok(hres == E_INVALIDARG, "got %08x\n", hres);
2007 
2008  hres = ICreateTypeLib2_CreateTypeInfo(createtl, interface1W, TKIND_INTERFACE, &createti);
2009  ok(hres == S_OK, "got %08x\n", hres);
2010 
2011  hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&interface1);
2012  ok(hres == S_OK, "got %08x\n", hres);
2013 
2014  hres = ITypeLib_GetDocumentation(tl, 0, &name, NULL, NULL, NULL);
2015  ok(hres == S_OK, "got %08x\n", hres);
2016  ok(!memcmp(name, interface1W, sizeof(interface1W)), "name = %s\n", wine_dbgstr_w(name));
2017 
2019 
2020  ITypeLib_Release(tl);
2021 
2022  name = (BSTR)0xdeadbeef;
2023  helpfile = (BSTR)0xdeadbeef;
2024  hres = ITypeInfo_GetDocumentation(interface1, -1, &name, &docstring, &helpcontext, &helpfile);
2025  ok(hres == S_OK, "got %08x\n", hres);
2026  ok(!memcmp(name, interface1W, sizeof(interface1W)), "name = %s\n", wine_dbgstr_w(name));
2027  ok(docstring == NULL, "docstring != NULL\n");
2028  ok(helpcontext == 0, "helpcontext != 0\n");
2029  ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "helpfile = %s\n", wine_dbgstr_w(helpfile));
2030 
2033 
2034  hres = ITypeInfo_GetDocumentation(interface1, 0, &name, NULL, NULL, NULL);
2035  ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2036 
2037  hres = ITypeInfo_GetRefTypeInfo(interface1, 0, NULL);
2038  ok(hres == E_INVALIDARG, "got %08x\n", hres);
2039 
2040 
2041  hres = ICreateTypeInfo_LayOut(createti);
2042  ok(hres == S_OK, "got %08x\n", hres);
2043 
2044  hres = ICreateTypeInfo_SetGuid(createti, &interfaceguid);
2045  ok(hres == S_OK, "got %08x\n", hres);
2046 
2047  hres = ICreateTypeInfo_AddRefTypeInfo(createti, NULL, &hreftype);
2048  ok(hres == E_INVALIDARG, "got %08x\n", hres);
2049 
2050  hres = ICreateTypeInfo_AddRefTypeInfo(createti, unknown, NULL);
2051  ok(hres == E_INVALIDARG, "got %08x\n", hres);
2052 
2053  hres = ICreateTypeInfo_AddRefTypeInfo(createti, unknown, &hreftype);
2054  ok(hres == S_OK, "got %08x\n", hres);
2055  if(hres != S_OK) {
2056  skip("Skipping some tests\n");
2057  return;
2058  }
2059 
2060  hres = ICreateTypeInfo_AddImplType(createti, 1, hreftype);
2061  ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2062 
2063  hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype);
2064  ok(hres == S_OK, "got %08x\n", hres);
2065 
2066  hres = ITypeInfo_GetRefTypeOfImplType(interface1, 0, &hreftype);
2067  ok(hres == S_OK, "got %08x\n", hres);
2068  ok(hreftype == 3, "hreftype = %d\n", hreftype);
2069 
2070  hres = ITypeInfo_GetRefTypeInfo(interface1, hreftype, &ti);
2071  ok(hres == S_OK, "got %08x\n", hres);
2072 
2073  hres = ITypeInfo_GetTypeAttr(ti, &typeattr);
2074  ok(hres == S_OK, "got %08x\n", hres);
2075  ok(typeattr->cbSizeVft == 3 * ptr_size, "retrieved IUnknown gave wrong cbSizeVft: %u\n", typeattr->cbSizeVft);
2076  ITypeInfo_ReleaseTypeAttr(ti, typeattr);
2077 
2078  ITypeInfo_Release(ti);
2079 
2080  hres = ITypeInfo_GetRefTypeOfImplType(interface1, -1, &hreftype);
2081  ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2082 
2083  ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo2, (void**)&ti2);
2084 
2085  memset(&funcdesc, 0, sizeof(FUNCDESC));
2086  funcdesc.funckind = FUNC_PUREVIRTUAL;
2087  funcdesc.invkind = INVOKE_PROPERTYGET;
2088  funcdesc.callconv = CC_STDCALL;
2089  funcdesc.elemdescFunc.tdesc.vt = VT_BSTR;
2090  U(funcdesc.elemdescFunc).idldesc.wIDLFlags = IDLFLAG_NONE;
2091 
2092  hres = ICreateTypeInfo_AddFuncDesc(createti, 0, NULL);
2093  ok(hres == E_INVALIDARG, "got %08x\n", hres);
2094 
2095  hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc);
2096  ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2097 
2098  hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc);
2099  ok(hres == S_OK, "got %08x\n", hres);
2100 
2101  hres = ITypeInfo2_GetFuncDesc(ti2, 0, NULL);
2102  ok(hres == E_INVALIDARG, "got %08x\n", hres);
2103 
2104  hres = ITypeInfo2_GetFuncDesc(ti2, 1, &pfuncdesc);
2105  ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2106 
2107  hres = ITypeInfo2_GetFuncDesc(ti2, 0, &pfuncdesc);
2108  ok(hres == S_OK, "got %08x\n", hres);
2109 
2110  ok(pfuncdesc->memid == 0, "got %x\n", pfuncdesc->memid);
2111  ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2112  ok(pfuncdesc->lprgelemdescParam == NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2113  ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2114  ok(pfuncdesc->invkind == INVOKE_PROPERTYGET, "got 0x%x\n", pfuncdesc->invkind);
2115  ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2116  ok(pfuncdesc->cParams == 0, "got %d\n", pfuncdesc->cParams);
2117  ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2118  ok(pfuncdesc->oVft == 3 * ptr_size, "got %d\n", pfuncdesc->oVft);
2119  ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2120  ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_BSTR, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2121  ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2122 
2123  ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2124 
2125  hres = ICreateTypeInfo_SetFuncHelpContext(createti, 0, 0xabcdefab);
2126  ok(hres == S_OK, "got %08x\n", hres);
2127 
2128  funcdesc.invkind = INVOKE_PROPERTYPUT;
2129  hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc);
2130  ok(hres == TYPE_E_INCONSISTENTPROPFUNCS, "got %08x\n", hres);
2131 
2132  funcdesc.invkind = INVOKE_PROPERTYPUTREF;
2133  hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc);
2134  ok(hres == TYPE_E_INCONSISTENTPROPFUNCS, "got %08x\n", hres);
2135 
2136  elemdesc[0].tdesc.vt = VT_BSTR;
2137  U(elemdesc[0]).idldesc.dwReserved = 0;
2138  U(elemdesc[0]).idldesc.wIDLFlags = IDLFLAG_FIN;
2139 
2140  funcdesc.lprgelemdescParam = elemdesc;
2141  funcdesc.invkind = INVOKE_PROPERTYPUT;
2142  funcdesc.cParams = 1;
2143  funcdesc.elemdescFunc.tdesc.vt = VT_VOID;
2144 
2145  hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc);
2146  ok(hres == S_OK, "got %08x\n", hres);
2147 
2148  hres = ICreateTypeInfo_SetFuncHelpContext(createti, 1, 0xabcdefab);
2149  ok(hres == S_OK, "got %08x\n", hres);
2150 
2151  hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, propname, 0);
2152  ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2153 
2154  hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, NULL, 1);
2155  ok(hres == E_INVALIDARG, "got %08x\n", hres);
2156 
2157  hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, propname, 1);
2158  ok(hres == S_OK, "got %08x\n", hres);
2159 
2160  hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 1, propname, 1);
2161  ok(hres == S_OK, "got %08x\n", hres);
2162 
2163  hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 1, propname, 2);
2164  ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2165 
2166  hres = ITypeInfo2_GetFuncDesc(ti2, 1, &pfuncdesc);
2167  ok(hres == S_OK, "got %08x\n", hres);
2168 
2169  ok(pfuncdesc->memid == 0, "got %x\n", pfuncdesc->memid);
2170  ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2171  ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2172  ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2173  ok(pfuncdesc->invkind == INVOKE_PROPERTYPUT, "got 0x%x\n", pfuncdesc->invkind);
2174  ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2175  ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2176  ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2177  ok(pfuncdesc->oVft == 4 * ptr_size, "got %d\n", pfuncdesc->oVft);
2178  ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2179  ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2180  ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2181 
2182  edesc = pfuncdesc->lprgelemdescParam;
2183  ok(edesc->tdesc.vt == VT_BSTR, "got: %d\n", edesc->tdesc.vt);
2184  ok(U(*edesc).idldesc.wIDLFlags == IDLFLAG_FIN, "got: %x\n", U(*edesc).idldesc.wIDLFlags);
2185 
2186  ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2187 
2188 
2189  funcdesc.invkind = INVOKE_PROPERTYPUTREF;
2190  hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc);
2191  ok(hres == S_OK, "got %08x\n", hres);
2192 
2193  hres = ICreateTypeInfo_SetFuncHelpContext(createti, 0, 0xabcdefab);
2194  ok(hres == S_OK, "got %08x\n", hres);
2195 
2196  hres = ICreateTypeInfo_SetFuncHelpContext(createti, 0, 0x201);
2197  ok(hres == S_OK, "got %08x\n", hres);
2198 
2199  funcdesc.memid = 1;
2200  funcdesc.lprgelemdescParam = NULL;
2201  funcdesc.invkind = INVOKE_FUNC;
2202  funcdesc.cParams = 0;
2203  funcdesc.cScodes = 1;
2204  funcdesc.lprgscode = NULL;
2205  hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc);
2206  ok(hres == S_OK, "got %08x\n", hres);
2207 
2208  hres = ITypeInfo2_GetFuncDesc(ti2, 1, &pfuncdesc);
2209  ok(hres == S_OK, "got %08x\n", hres);
2210 
2211  ok(pfuncdesc->memid == 1, "got %d\n", pfuncdesc->memid);
2212  ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2213  ok(pfuncdesc->lprgelemdescParam == NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2214  ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2215  ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2216  ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2217  ok(pfuncdesc->cParams == 0, "got %d\n", pfuncdesc->cParams);
2218  ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2219  ok(pfuncdesc->oVft == 4 * ptr_size, "got %d\n", pfuncdesc->oVft);
2220  ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2221  ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2222  ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2223 
2224  ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2225 
2226  funcdesc.memid = MEMBERID_NIL;
2227  hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc);
2228  ok(hres == S_OK, "got %08x\n", hres);
2229 
2230  elemdesc[0].tdesc.vt = VT_PTR;
2231  U(elemdesc[0].tdesc).lptdesc = &typedesc1;
2232  typedesc1.vt = VT_BSTR;
2233  funcdesc.cParams = 1;
2234  funcdesc.lprgelemdescParam = elemdesc;
2235  hres = ICreateTypeInfo_AddFuncDesc(createti, 4, &funcdesc);
2236  ok(hres == S_OK, "got %08x\n", hres);
2237 
2238  hres = ITypeInfo2_GetFuncDesc(ti2, 4, &pfuncdesc);
2239  ok(hres == S_OK, "got %08x\n", hres);
2240 
2241  ok(pfuncdesc->memid == 0x60010004, "got %x\n", pfuncdesc->memid);
2242  ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2243  ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2244  ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2245  ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2246  ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2247  ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2248  ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2249  ok(pfuncdesc->oVft == 7 * ptr_size, "got %d\n", pfuncdesc->oVft);
2250  ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2251  ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2252  ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2253 
2254  edesc = pfuncdesc->lprgelemdescParam;
2255  ok(edesc->tdesc.vt == VT_PTR, "got: %d\n", edesc->tdesc.vt);
2256  ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FIN, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2257  ok(U(*edesc).paramdesc.pparamdescex == NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2258  ok(U(edesc->tdesc).lptdesc != NULL, "got: %p\n", U(edesc->tdesc).lptdesc);
2259  ok(U(edesc->tdesc).lptdesc->vt == VT_BSTR, "got: %d\n", U(edesc->tdesc).lptdesc->vt);
2260 
2261  ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2262 
2263  U(elemdesc[0].tdesc).lptdesc = &typedesc2;
2264  typedesc2.vt = VT_PTR;
2265  U(typedesc2).lptdesc = &typedesc1;
2266  hres = ICreateTypeInfo_AddFuncDesc(createti, 4, &funcdesc);
2267  ok(hres == S_OK, "got %08x\n", hres);
2268 
2269  hres = ITypeInfo2_GetFuncDesc(ti2, 4, &pfuncdesc);
2270  ok(hres == S_OK, "got %08x\n", hres);
2271 
2272  ok(pfuncdesc->memid == 0x60010007, "got %x\n", pfuncdesc->memid);
2273  ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2274  ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2275  ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2276  ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2277  ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2278  ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2279  ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2280  ok(pfuncdesc->oVft == 7 * ptr_size, "got %d\n", pfuncdesc->oVft);
2281  ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2282  ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2283  ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2284 
2285  edesc = pfuncdesc->lprgelemdescParam;
2286  ok(edesc->tdesc.vt == VT_PTR, "got: %d\n", edesc->tdesc.vt);
2287  ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FIN, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2288  ok(U(*edesc).paramdesc.pparamdescex == NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2289  ok(U(edesc->tdesc).lptdesc != NULL, "got: %p\n", U(edesc->tdesc).lptdesc);
2290  ok(U(edesc->tdesc).lptdesc->vt == VT_PTR, "got: %d\n", U(edesc->tdesc).lptdesc->vt);
2291  ok(U(*U(edesc->tdesc).lptdesc).lptdesc != NULL, "got: %p\n", U(*U(edesc->tdesc).lptdesc).lptdesc);
2292  ok(U(*U(edesc->tdesc).lptdesc).lptdesc->vt == VT_BSTR, "got: %d\n", U(*U(edesc->tdesc).lptdesc).lptdesc->vt);
2293 
2294  ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2295 
2296  elemdesc[0].tdesc.vt = VT_INT;
2297  U(elemdesc[0]).paramdesc.wParamFlags = PARAMFLAG_FHASDEFAULT;
2298  U(elemdesc[0]).paramdesc.pparamdescex = &paramdescex;
2299  V_VT(&paramdescex.varDefaultValue) = VT_INT;
2300  V_INT(&paramdescex.varDefaultValue) = 0x123;
2301  hres = ICreateTypeInfo_AddFuncDesc(createti, 3, &funcdesc);
2302  ok(hres == S_OK, "got %08x\n", hres);
2303 
2304  hres = ITypeInfo2_GetFuncDesc(ti2, 3, &pfuncdesc);
2305  ok(hres == S_OK, "got %08x\n", hres);
2306 
2307  ok(pfuncdesc->memid == 0x60010003, "got %x\n", pfuncdesc->memid);
2308  ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2309  ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2310  ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2311  ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2312  ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2313  ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2314  ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2315  ok(pfuncdesc->oVft == 6 * ptr_size, "got %d\n", pfuncdesc->oVft);
2316  ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2317  ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2318  ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2319 
2320  edesc = pfuncdesc->lprgelemdescParam;
2321  ok(edesc->tdesc.vt == VT_INT, "got: %d\n", edesc->tdesc.vt);
2322  ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2323  ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2324  ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
2325  U(*edesc).paramdesc.pparamdescex->cBytes);
2326  ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_I4, "got: %d\n",
2327  V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2328  ok(V_I4(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0x123, "got: 0x%x\n",
2329  V_I4(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2330 
2331  ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2332 
2333  U(elemdesc[0]).idldesc.dwReserved = 0;
2334  U(elemdesc[0]).idldesc.wIDLFlags = IDLFLAG_FIN;
2335  elemdesc[1].tdesc.vt = VT_UI2;
2336  U(elemdesc[1]).paramdesc.wParamFlags = PARAMFLAG_FHASDEFAULT;
2337  U(elemdesc[1]).paramdesc.pparamdescex = &paramdescex;
2338  V_VT(&paramdescex.varDefaultValue) = VT_UI2;
2339  V_UI2(&paramdescex.varDefaultValue) = 0xffff;
2340  funcdesc.cParams = 2;
2341  hres = ICreateTypeInfo_AddFuncDesc(createti, 3, &funcdesc);
2342  ok(hres == S_OK, "got %08x\n", hres);
2343 
2344  hres = ITypeInfo2_GetFuncDesc(ti2, 3, &pfuncdesc);
2345  ok(hres == S_OK, "got %08x\n", hres);
2346 
2347  ok(pfuncdesc->memid == 0x60010009, "got %x\n", pfuncdesc->memid);
2348  ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2349  ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2350  ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2351  ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2352  ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2353  ok(pfuncdesc->cParams == 2, "got %d\n", pfuncdesc->cParams);
2354  ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2355  ok(pfuncdesc->oVft == 6 * ptr_size, "got %d\n", pfuncdesc->oVft);
2356  ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2357  ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2358  ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2359 
2360  edesc = pfuncdesc->lprgelemdescParam;
2361  ok(edesc->tdesc.vt == VT_INT, "got: %d\n", edesc->tdesc.vt);
2362  ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FIN, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2363  ok(U(*edesc).paramdesc.pparamdescex == NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2364 
2365  edesc = pfuncdesc->lprgelemdescParam + 1;
2366  ok(edesc->tdesc.vt == VT_UI2, "got: %d\n", edesc->tdesc.vt);
2367  ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2368  ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2369  ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
2370  U(*edesc).paramdesc.pparamdescex->cBytes);
2371  ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_UI2, "got: %d\n",
2372  V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2373  ok(V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0xFFFF, "got: 0x%x\n",
2374  V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2375 
2376  ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2377 
2378  U(elemdesc[0]).paramdesc.wParamFlags = PARAMFLAG_FHASDEFAULT;
2379  U(elemdesc[0]).paramdesc.pparamdescex = &paramdescex;
2380  elemdesc[1].tdesc.vt = VT_INT;
2381  V_VT(&paramdescex.varDefaultValue) = VT_INT;
2382  V_INT(&paramdescex.varDefaultValue) = 0xffffffff;
2383  hres = ICreateTypeInfo_AddFuncDesc(createti, 3, &funcdesc);
2384  ok(hres == S_OK, "got %08x\n", hres);
2385 
2386  elemdesc[0].tdesc.vt = VT_BSTR;
2387  elemdesc[1].tdesc.vt = VT_BSTR;
2388  V_VT(&paramdescex.varDefaultValue) = VT_BSTR;
2389  V_BSTR(&paramdescex.varDefaultValue) = SysAllocString(defaultW);
2390  hres = ICreateTypeInfo_AddFuncDesc(createti, 3, &funcdesc);
2391  ok(hres == S_OK, "got %08x\n", hres);
2392  SysFreeString(V_BSTR(&paramdescex.varDefaultValue));
2393 
2394  WideCharToMultiByte(CP_ACP, 0, defaultW, -1, nameA, sizeof(nameA), NULL, NULL);
2395  MultiByteToWideChar(CP_ACP, 0, nameA, -1, nameW, sizeof(nameW)/sizeof(nameW[0]));
2396 
2397  hres = ITypeInfo2_GetFuncDesc(ti2, 3, &pfuncdesc);
2398  ok(hres == S_OK, "got %08x\n", hres);
2399 
2400  ok(pfuncdesc->memid == 0x6001000b, "got %x\n", pfuncdesc->memid);
2401  ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2402  ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2403  ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2404  ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2405  ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2406  ok(pfuncdesc->cParams == 2, "got %d\n", pfuncdesc->cParams);
2407  ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2408  ok(pfuncdesc->oVft == 6 * ptr_size, "got %d\n", pfuncdesc->oVft);
2409  ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2410  ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2411  ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2412 
2413  edesc = pfuncdesc->lprgelemdescParam;
2414  ok(edesc->tdesc.vt == VT_BSTR, "got: %d\n", edesc->tdesc.vt);
2415  ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2416  ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2417  ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
2418  U(*edesc).paramdesc.pparamdescex->cBytes);
2419  ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_BSTR, "got: %d\n",
2420  V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2421  ok(!lstrcmpW(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue), nameW),
2422  "got: %s\n",
2423  wine_dbgstr_w(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue)));
2424 
2425  edesc = pfuncdesc->lprgelemdescParam + 1;
2426  ok(edesc->tdesc.vt == VT_BSTR, "got: %d\n", edesc->tdesc.vt);
2427  ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2428  ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2429  ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
2430  U(*edesc).paramdesc.pparamdescex->cBytes);
2431  ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_BSTR, "got: %d\n",
2432  V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2433  ok(!lstrcmpW(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue), nameW),
2434  "got: %s\n",
2435  wine_dbgstr_w(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue)));
2436 
2437  ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2438 
2439  elemdesc[0].tdesc.vt = VT_USERDEFINED;
2440  U(elemdesc[0].tdesc).hreftype = hreftype;
2441  U(elemdesc[0]).paramdesc.pparamdescex = &paramdescex;
2442  U(elemdesc[0]).paramdesc.wParamFlags = PARAMFLAG_FHASDEFAULT;
2443  V_VT(&paramdescex.varDefaultValue) = VT_INT;
2444  V_INT(&paramdescex.varDefaultValue) = 0x789;
2445 
2446  funcdesc.lprgelemdescParam = elemdesc;
2447  funcdesc.invkind = INVOKE_FUNC;
2448  funcdesc.cParams = 1;
2449  funcdesc.elemdescFunc.tdesc.vt = VT_VOID;
2450 
2451  hres = ICreateTypeInfo_AddFuncDesc(createti, 5, &funcdesc);
2452  ok(hres == S_OK, "got %08x\n", hres);
2453 
2454  hres = ITypeInfo2_GetFuncDesc(ti2, 5, &pfuncdesc);
2455  ok(hres == S_OK, "got %08x\n", hres);
2456 
2457  ok(pfuncdesc->memid == 0x60010005, "got %x\n", pfuncdesc->memid);
2458  ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2459  ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2460  ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2461  ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2462  ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2463  ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2464  ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2465  ok(pfuncdesc->oVft == 8 * ptr_size, "got %d\n", pfuncdesc->oVft);
2466  ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2467  ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2468  ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2469 
2470  edesc = pfuncdesc->lprgelemdescParam;
2471  ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2472  ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT,
2473  "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2474  ok(edesc->tdesc.vt == VT_USERDEFINED, "got: %d\n", edesc->tdesc.vt);
2475  ok(U(edesc->tdesc).hreftype == hreftype, "got: 0x%x\n", U(edesc->tdesc).hreftype);
2476  ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_INT, "got: %d\n",
2477  V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2478  ok(V_INT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0x789, "got: %d\n",
2479  V_INT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2480 
2481  ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2482 
2483  elemdesc[0].tdesc.vt = VT_VARIANT;
2484  U(elemdesc[0]).paramdesc.pparamdescex = &paramdescex;
2485  U(elemdesc[0]).paramdesc.wParamFlags = PARAMFLAG_FHASDEFAULT;
2486  V_VT(&paramdescex.varDefaultValue) = VT_INT;
2487  V_INT(&paramdescex.varDefaultValue) = 3;
2488 
2489  funcdesc.lprgelemdescParam = elemdesc;
2490  funcdesc.invkind = INVOKE_FUNC;
2491  funcdesc.cParams = 1;
2492  funcdesc.elemdescFunc.tdesc.vt = VT_VARIANT;
2493 
2494  hres = ICreateTypeInfo_AddFuncDesc(createti, 6, &funcdesc);
2495  ok(hres == S_OK, "got %08x\n", hres);
2496 
2497  hres = ITypeInfo2_GetFuncDesc(ti2, 6, &pfuncdesc);
2498  ok(hres == S_OK, "got %08x\n", hres);
2499 
2500  ok(pfuncdesc->memid == 0x60010006, "got %x\n", pfuncdesc->memid);
2501  ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2502  ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2503  ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2504  ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2505  ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2506  ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2507  ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2508  ok(pfuncdesc->oVft == 9 * ptr_size, "got %d\n", pfuncdesc->oVft);
2509  ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2510  ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VARIANT, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2511  ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2512 
2513  edesc = pfuncdesc->lprgelemdescParam;
2514  ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2515  ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT,
2516  "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2517  ok(edesc->tdesc.vt == VT_VARIANT, "got: %d\n", edesc->tdesc.vt);
2518  ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_INT, "got: %d\n",
2519  V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2520  ok(V_INT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 3, "got: %d\n",
2521  V_INT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2522 
2523  ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2524 
2525  hres = ITypeInfo_GetDocumentation(interface1, 0, &name, &docstring, &helpcontext, &helpfile);
2526  ok(hres == S_OK, "got %08x\n", hres);
2527  ok(name == NULL, "name != NULL\n");
2528  ok(docstring == NULL, "docstring != NULL\n");
2529  ok(helpcontext == 0x201, "helpcontext != 0x201\n");
2530  ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "helpfile = %s\n", wine_dbgstr_w(helpfile));
2531 
2533 
2534  hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 1000, NULL, 1);
2535  ok(hres == E_INVALIDARG, "got %08x\n", hres);
2536 
2537  hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 1000, names1, 1);
2538  ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2539 
2540  hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, names1, 2);
2541  ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2542 
2543  hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, names2, 1);
2544  ok(hres == S_OK, "got %08x\n", hres);
2545 
2546  hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, names1, 1);
2547  ok(hres == S_OK, "got %08x\n", hres);
2548 
2549  hres = ITypeInfo_GetDocumentation(interface1, 0, &name, NULL, NULL, NULL);
2550  ok(hres == S_OK, "got %08x\n", hres);
2551  ok(!memcmp(name, func1W, sizeof(func1W)), "name = %s\n", wine_dbgstr_w(name));
2552 
2554 
2555  hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 3, names2, 3);
2556  ok(hres == S_OK, "got %08x\n", hres);
2557 
2558  hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 3, names1, 3);
2559  ok(hres == TYPE_E_AMBIGUOUSNAME, "got %08x\n", hres);
2560 
2561  ITypeInfo2_Release(ti2);
2562  ICreateTypeInfo_Release(createti);
2563 
2564  hres = ICreateTypeLib2_CreateTypeInfo(createtl, interface1W, TKIND_INTERFACE, &createti);
2565  ok(hres == TYPE_E_NAMECONFLICT, "got %08x\n", hres);
2566 
2567  hres = ICreateTypeLib2_CreateTypeInfo(createtl, interface2W, TKIND_INTERFACE, &createti);
2568  ok(hres == S_OK, "got %08x\n", hres);
2569 
2570  hres = ICreateTypeInfo_SetGuid(createti, &interface2guid);
2571  ok(hres == S_OK, "got %08x\n", hres);
2572 
2573  hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&interface2);
2574  ok(hres == S_OK, "got %08x\n", hres);
2575 
2576  hres = ITypeInfo_GetRefTypeOfImplType(interface2, 0, &hreftype);
2577  ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2578 
2579  hres = ICreateTypeInfo_AddRefTypeInfo(createti, interface1, &hreftype);
2580  ok(hres == S_OK, "got %08x\n", hres);
2581 
2582  hres = ITypeInfo_GetRefTypeInfo(interface2, 0, &ti);
2583  ok(hres == S_OK, "got %08x\n", hres);
2584  ok(ti == interface1, "Received and added interfaces are different\n");
2585 
2586  ITypeInfo_Release(ti);
2587 
2588  hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype);
2589  ok(hres == S_OK, "got %08x\n", hres);
2590 
2591  hres = ITypeInfo_GetRefTypeOfImplType(interface2, 0, &hreftype);
2592  ok(hres == S_OK, "got %08x\n", hres);
2593  ok(hreftype == 2, "hreftype = %d\n", hreftype);
2594 
2595  hres = ITypeInfo_GetRefTypeOfImplType(interface2, -1, &hreftype);
2596  ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2597 
2598  hres = ICreateTypeInfo_SetImplTypeFlags(createti, 0, IMPLTYPEFLAG_FDEFAULT);
2599  ok(hres == TYPE_E_BADMODULEKIND, "got %08x\n", hres);
2600 
2601  hres = ITypeInfo_GetImplTypeFlags(interface2, 0, &impltypeflags);
2602  ok(hres == S_OK, "got %08x\n", hres);
2603  ok(impltypeflags == 0, "impltypeflags = %x\n", impltypeflags);
2604 
2605  hres = ITypeInfo_GetImplTypeFlags(interface2, 1, &impltypeflags);
2606  ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2607 
2608  funcdesc.elemdescFunc.tdesc.vt = VT_VOID;
2609  funcdesc.oVft = 0xaaac;
2610  hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc);
2611  if(sys == SYS_WIN64){
2612  ok(hres == E_INVALIDARG, "got %08x\n", hres);
2613  funcdesc.oVft = 0xaab0;
2614  hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc);
2615  }
2616  ok(hres == S_OK, "got %08x\n", hres);
2617  funcdesc.oVft = 0xaaa8;
2618  hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc);
2619  ok(hres == S_OK, "got %08x\n", hres);
2620 
2621  hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&ti2);
2622  ok(hres == S_OK, "got %08x\n", hres);
2623 
2624  hres = ITypeInfo2_GetFuncDesc(ti2, 0, &pfuncdesc);
2625  ok(hres == S_OK, "got %08x\n", hres);
2626 
2627  ok(pfuncdesc->memid == 0x60020000, "got %x\n", pfuncdesc->memid);
2628  ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2629  ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2630  ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2631  ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2632  ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2633  ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2634  ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2635  ok(pfuncdesc->oVft == (short)0xaaa8, "got %d\n", pfuncdesc->oVft);
2636  ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2637  ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2638  ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2639 
2640  ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2641  ITypeInfo2_Release(ti2);
2642 
2643  funcdesc.oVft = 0;
2644 
2645  ICreateTypeInfo_Release(createti);
2646 
2647  VariantInit(&cust_data);
2648 
2649  hres = ICreateTypeLib2_CreateTypeInfo(createtl, interface3W, TKIND_INTERFACE, &createti);
2650  ok(hres == S_OK, "got %08x\n", hres);
2651 
2652  hres = ICreateTypeInfo_QueryInterface(createti, &IID_ICreateTypeInfo2, (void**)&createti2);
2653  ok(hres == S_OK, "got %08x\n", hres);
2654 
2655  hres = ICreateTypeInfo2_QueryInterface(createti2, &IID_ITypeInfo2, (void**)&ti2);
2656  ok(hres == S_OK, "got %08x\n", hres);
2657 
2658  hres = ITypeInfo2_GetCustData(ti2, NULL, NULL);
2659  ok(hres == E_INVALIDARG, "got %08x\n", hres);
2660 
2661  hres = ITypeInfo2_GetCustData(ti2, &custguid, NULL);
2662  ok(hres == E_INVALIDARG, "got %08x\n", hres);
2663 
2664  hres = ITypeInfo2_GetCustData(ti2, &custguid, &cust_data);
2665  ok(hres == S_OK, "got %08x\n", hres);
2666 
2667  hres = ICreateTypeInfo2_SetCustData(createti2, NULL, NULL);
2668  ok(hres == E_INVALIDARG, "got %08x\n", hres);
2669 
2670  hres = ICreateTypeInfo2_SetCustData(createti2, &custguid, NULL);
2671  ok(hres == E_INVALIDARG, "got %08x\n", hres);
2672 
2673  hres = ICreateTypeInfo2_SetCustData(createti2, &custguid, &cust_data);
2674  ok(hres == DISP_E_BADVARTYPE, "got %08x\n", hres);
2675 
2676  V_VT(&cust_data) = VT_UI4;
2677  V_I4(&cust_data) = 0xdeadbeef;
2678 
2679  hres = ICreateTypeInfo2_SetCustData(createti2, &custguid, &cust_data);
2680  ok(hres == S_OK, "got %08x\n", hres);
2681 
2682  V_I4(&cust_data) = 0;
2683  V_VT(&cust_data) = VT_EMPTY;
2684 
2685  hres = ITypeInfo2_GetCustData(ti2, &custguid, &cust_data);
2686  ok(hres == S_OK, "got %08x\n", hres);
2687 
2688  ok(V_VT(&cust_data) == VT_UI4, "got %d\n", V_VT(&cust_data));
2689  ok(V_I4(&cust_data) == 0xdeadbeef, "got 0x%08x\n", V_I4(&cust_data));
2690 
2691  V_VT(&cust_data) = VT_UI4;
2692  V_I4(&cust_data) = 12345678;
2693 
2694  hres = ICreateTypeInfo2_SetCustData(createti2, &custguid, &cust_data);
2695  ok(hres == S_OK, "got %08x\n", hres);
2696 
2697  V_I4(&cust_data) = 0;
2698  V_VT(&cust_data) = VT_EMPTY;
2699 
2700  hres = ITypeInfo2_GetCustData(ti2, &custguid, &cust_data);
2701  ok(hres == S_OK, "got %08x\n", hres);
2702 
2703  ok(V_VT(&cust_data) == VT_UI4, "got %d\n", V_VT(&cust_data));
2704  ok(V_I4(&cust_data) == 12345678, "got 0x%08x\n", V_I4(&cust_data));
2705 
2706  V_VT(&cust_data) = VT_BSTR;
2707  V_BSTR(&cust_data) = SysAllocString(asdfW);
2708 
2709  hres = ICreateTypeInfo2_SetCustData(createti2, &custguid, &cust_data);
2710  ok(hres == S_OK, "got %08x\n", hres);
2711 
2712  SysFreeString(V_BSTR(&cust_data));
2713  V_I4(&cust_data) = 0;
2714  V_VT(&cust_data) = VT_EMPTY;
2715 
2716  hres = ITypeInfo2_GetCustData(ti2, &custguid, &cust_data);
2717  ok(hres == S_OK, "got %08x\n", hres);
2718 
2719  ok(V_VT(&cust_data) == VT_BSTR, "got %d\n", V_VT(&cust_data));
2720  ok(!lstrcmpW(V_BSTR(&cust_data), asdfW), "got %s\n", wine_dbgstr_w(V_BSTR(&cust_data)));
2721  SysFreeString(V_BSTR(&cust_data));
2722 
2723  V_VT(&cust_data) = VT_UI4;
2724  V_UI4(&cust_data) = 17;
2725 
2726  hres = ITypeInfo2_GetCustData(ti2, &bogusguid, &cust_data);
2727  ok(hres == S_OK, "got %08x\n", hres);
2728 
2729  ok(V_VT(&cust_data) == VT_EMPTY, "got: %d\n", V_VT(&cust_data));
2730 
2731  ITypeInfo2_Release(ti2);
2732  ICreateTypeInfo2_Release(createti2);
2733  ICreateTypeInfo_Release(createti);
2734 
2735  hres = ICreateTypeLib2_CreateTypeInfo(createtl, coclassW, TKIND_COCLASS, &createti);
2736  ok(hres == S_OK, "got %08x\n", hres);
2737 
2738  hres = ICreateTypeInfo_AddRefTypeInfo(createti, interface1, &hreftype);
2739  ok(hres == S_OK, "got %08x\n", hres);
2740 
2741  hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype);
2742  ok(hres == S_OK, "got %08x\n", hres);
2743 
2744  hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype);
2745  ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2746 
2747  hres = ICreateTypeInfo_AddRefTypeInfo(createti, unknown, &hreftype);
2748  ok(hres == S_OK, "got %08x\n", hres);
2749 
2750  hres = ICreateTypeInfo_AddImplType(createti, 1, hreftype);
2751  ok(hres == S_OK, "got %08x\n", hres);
2752 
2753  hres = ICreateTypeInfo_AddImplType(createti, 1, hreftype);
2754  ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2755 
2756  hres = ICreateTypeInfo_AddImplType(createti, 2, hreftype);
2757  ok(hres == S_OK, "got %08x\n", hres);
2758 
2759  hres = ICreateTypeInfo_SetImplTypeFlags(createti, 0, IMPLTYPEFLAG_FDEFAULT);
2760  ok(hres == S_OK, "got %08x\n", hres);
2761 
2762  hres = ICreateTypeInfo_SetImplTypeFlags(createti, 1, IMPLTYPEFLAG_FRESTRICTED);
2763  ok(hres == S_OK, "got %08x\n", hres);
2764 
2765  hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&ti);
2766  ok(hres == S_OK, "got %08x\n", hres);
2767 
2768  hres = ITypeInfo_GetImplTypeFlags(ti, 0, NULL);
2769  ok(hres == E_INVALIDARG, "got %08x\n", hres);
2770 
2771  hres = ITypeInfo_GetImplTypeFlags(ti, 0, &impltypeflags);
2772  ok(hres == S_OK, "got %08x\n", hres);
2773  ok(impltypeflags == IMPLTYPEFLAG_FDEFAULT, "impltypeflags = %x\n", impltypeflags);
2774 
2775  hres = ITypeInfo_GetImplTypeFlags(ti, 1, &impltypeflags);
2776  ok(hres == S_OK, "got %08x\n", hres);
2777  ok(impltypeflags == IMPLTYPEFLAG_FRESTRICTED, "impltypeflags = %x\n", impltypeflags);
2778 
2779  hres = ITypeInfo_GetImplTypeFlags(ti, 2, &impltypeflags);
2780  ok(hres == S_OK, "got %08x\n", hres);
2781  ok(impltypeflags == 0, "impltypeflags = %x\n", impltypeflags);
2782 
2783  hres = ITypeInfo_GetRefTypeOfImplType(ti, 0, &hreftype);
2784  ok(hres == S_OK, "got %08x\n", hres);
2785  ok(hreftype == 0, "hreftype = %d\n", hreftype);
2786 
2787  hres = ITypeInfo_GetRefTypeOfImplType(ti, 1, &hreftype);
2788  ok(hres == S_OK, "got %08x\n", hres);
2789  ok(hreftype == 1, "hreftype = %d\n", hreftype);
2790 
2791  hres = ITypeInfo_GetRefTypeOfImplType(ti, 2, &hreftype);
2792  ok(hres == S_OK, "got %08x\n", hres);
2793  ok(hreftype == 1, "hreftype = %d\n", hreftype);
2794 
2795  hres = ITypeInfo_GetRefTypeOfImplType(ti, -1, &hreftype);
2796  ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2797 
2798  ITypeInfo_Release(ti);
2799 
2800  ICreateTypeInfo_Release(createti);
2801 
2802  hres = ICreateTypeLib2_CreateTypeInfo(createtl, dualW, TKIND_INTERFACE, &createti);
2803  ok(hres == S_OK, "got %08x\n", hres);
2804 
2805  hres = ICreateTypeInfo_SetTypeFlags(createti, TYPEFLAG_FDUAL);
2806  ok(hres == S_OK, "got %08x\n", hres);
2807 
2808  hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc);
2809  ok(hres == S_OK, "got %08x\n", hres);
2810 
2811  hres = ICreateTypeInfo_AddRefTypeInfo(createti, dispatch, &hreftype);
2812  ok(hres == S_OK, "got %08x\n", hres);
2813 
2814  hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype);
2815  ok(hres == S_OK, "got %08x\n", hres);
2816 
2817  hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&dual);
2818  ok(hres == S_OK, "got %08x\n", hres);
2819 
2820  hres = ITypeInfo_GetTypeAttr(dual, &typeattr);
2821  ok(hres == S_OK, "got %08x\n", hres);
2822  ok(typeattr->cbSizeInstance == ptr_size, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2823  ok(typeattr->typekind == 3, "typekind = %d\n", typeattr->typekind);
2824  ok(typeattr->cFuncs == 1, "cFuncs = %d\n", typeattr->cFuncs);
2825  ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2826  ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
2827  ok(typeattr->cbSizeVft == 8 * ptr_size, "cbSizeVft = %d\n", typeattr->cbSizeVft);
2828  ok(typeattr->cbAlignment == 4, "cbAlignment = %d\n", typeattr->cbAlignment);
2829  ok(typeattr->wTypeFlags == (TYPEFLAG_FDISPATCHABLE|TYPEFLAG_FDUAL), "wTypeFlags = %d\n", typeattr->wTypeFlags);
2830  ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2831  ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2832 
2833  ITypeInfo_ReleaseTypeAttr(dual, typeattr);
2834 
2835  hres = ITypeInfo_GetRefTypeOfImplType(dual, -1, &hreftype);
2836  ok(hres == S_OK, "got %08x\n", hres);
2837  ok(hreftype == -2, "got %08x\n", hreftype);
2838 
2839  hres = ITypeInfo_GetRefTypeInfo(dual, -2, &ti);
2840  ok(hres == S_OK, "got %08x\n", hres);
2841 
2842  hres = ITypeInfo_GetTypeAttr(ti, &typeattr);
2843  ok(hres == S_OK, "got %08x\n", hres);
2844  ok(typeattr->cbSizeInstance == ptr_size, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2845  ok(typeattr->typekind == 4, "typekind = %d\n", typeattr->typekind);
2846  ok(typeattr->cFuncs == 8, "cFuncs = %d\n", typeattr->cFuncs);
2847  ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2848  ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
2849  ok(typeattr->cbSizeVft == 7 * sizeof(void *), "cbSizeVft = %d\n", typeattr->cbSizeVft);
2850  ok(typeattr->cbAlignment == 4, "cbAlignment = %d\n", typeattr->cbAlignment);
2851  ok(typeattr->wTypeFlags == (TYPEFLAG_FDISPATCHABLE|TYPEFLAG_FDUAL), "wTypeFlags = %d\n", typeattr->wTypeFlags);
2852  ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2853  ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2854 
2855  ITypeInfo_ReleaseTypeAttr(ti, typeattr);
2856 
2857  ITypeInfo_Release(ti);
2858 
2859  hres = ICreateTypeInfo_SetTypeDescAlias(createti, &typedesc1);
2860  ok(hres == TYPE_E_BADMODULEKIND, "got %08x\n", hres);
2861 
2862  ICreateTypeInfo_Release(createti);
2863 
2864  hres = ITypeInfo_GetTypeAttr(interface1, &typeattr);
2865  ok(hres == S_OK, "got %08x\n", hres);
2866  ok(typeattr->cbSizeInstance == ptr_size, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2867  ok(typeattr->typekind == 3, "typekind = %d\n", typeattr->typekind);
2868  ok(typeattr->cFuncs == 13, "cFuncs = %d\n", typeattr->cFuncs);
2869  ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2870  ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
2871  ok(typeattr->cbSizeVft == 16 * ptr_size, "cbSizeVft = %d\n", typeattr->cbSizeVft);
2872  ok(typeattr->cbAlignment == 4, "cbAlignment = %d\n", typeattr->cbAlignment);
2873  ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
2874  ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2875  ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2876 
2877  ITypeInfo_ReleaseTypeAttr(interface1, typeattr);
2878 
2879  hres = ITypeInfo_GetTypeAttr(interface2, &typeattr);
2880  ok(hres == S_OK, "got %08x\n", hres);
2881  ok(typeattr->cbSizeInstance == ptr_size, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2882  ok(typeattr->typekind == 3, "typekind = %d\n", typeattr->typekind);
2883  ok(typeattr->cFuncs == 2, "cFuncs = %d\n", typeattr->cFuncs);
2884  ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2885  ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
2886  ok((sys == SYS_WIN32 && typeattr->cbSizeVft == 0xaab0) ||
2887  (sys == SYS_WIN64 && typeattr->cbSizeVft == 0xaab8),
2888  "cbSizeVft = 0x%x\n", typeattr->cbSizeVft);
2889  ok(typeattr->cbAlignment == 4, "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 
2894  ITypeInfo_ReleaseTypeAttr(interface2, typeattr);
2895 
2896  ok(ITypeInfo_Release(interface2)==0, "Object should be freed\n");
2897  ok(ITypeInfo_Release(interface1)==0, "Object should be freed\n");
2898  ok(ITypeInfo_Release(dual)==0, "Object should be freed\n");
2899 
2900  hres = ICreateTypeLib2_CreateTypeInfo(createtl, aliasW, TKIND_ALIAS, &createti);
2901  ok(hres == S_OK, "got %08x\n", hres);
2902 
2903  hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&interface1);
2904  ok(hres == S_OK, "got %08x\n", hres);
2905 
2906  if(0){
2907  /* windows gives invalid values here, and even breaks the typeinfo permanently
2908  * on winxp. only call GetTypeAttr() on a TKIND_ALIAS after SetTypeDescAlias. */
2909  hres = ITypeInfo_GetTypeAttr(interface1, &typeattr);
2910  ok(hres == S_OK, "got %08x\n", hres);
2911  ok(typeattr->cbSizeInstance == 0xffffffb4, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2912  ok(typeattr->typekind == TKIND_ALIAS, "typekind = %d\n", typeattr->typekind);
2913  ok(typeattr->cFuncs == 0, "cFuncs = %d\n", typeattr->cFuncs);
2914  ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2915  ok(typeattr->cImplTypes == 0, "cImplTypes = %d\n", typeattr->cImplTypes);
2916  ok(typeattr->cbSizeVft == 0, "cbSizeVft = %d\n", typeattr->cbSizeVft);
2917  ok(typeattr->cbAlignment == 0, "cbAlignment = %d\n", typeattr->cbAlignment);
2918  ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
2919  ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2920  ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2921  ok(typeattr->tdescAlias.vt == VT_EMPTY, "Got wrong tdescAlias.vt: %u\n", typeattr->tdescAlias.vt);
2922  ITypeInfo_ReleaseTypeAttr(interface1, typeattr);
2923  }
2924 
2925  hres = ICreateTypeInfo_SetTypeDescAlias(createti, NULL);
2926  ok(hres == E_INVALIDARG, "got %08x\n", hres);
2927 
2928  typedesc1.vt = VT_I1;
2929  hres = ICreateTypeInfo_SetTypeDescAlias(createti, &typedesc1);
2930  ok(hres == S_OK, "got %08x\n", hres);
2931 
2932  hres = ITypeInfo_GetTypeAttr(interface1, &typeattr);
2933  ok(hres == S_OK, "got %08x\n", hres);
2934  ok(typeattr->cbSizeInstance == 1, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2935  ok(typeattr->typekind == TKIND_ALIAS, "typekind = %d\n", typeattr->typekind);
2936  ok(typeattr->cFuncs == 0, "cFuncs = %d\n", typeattr->cFuncs);
2937  ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2938  ok(typeattr->cImplTypes == 0, "cImplTypes = %d\n", typeattr->cImplTypes);
2939  ok(typeattr->cbSizeVft == 0, "cbSizeVft = %d\n", typeattr->cbSizeVft);
2940  ok(typeattr->cbAlignment == 1, "cbAlignment = %d\n", typeattr->cbAlignment);
2941  ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
2942  ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2943  ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2944  ok(typeattr->tdescAlias.vt == VT_I1, "Got wrong tdescAlias.vt: %u\n", typeattr->tdescAlias.vt);
2945  ITypeInfo_ReleaseTypeAttr(interface1, typeattr);
2946 
2947  typedesc1.vt = VT_R8;
2948  hres = ICreateTypeInfo_SetTypeDescAlias(createti, &typedesc1);
2949  ok(hres == S_OK, "got %08x\n", hres);
2950 
2951  hres = ITypeInfo_GetTypeAttr(interface1, &typeattr);
2952  ok(hres == S_OK, "got %08x\n", hres);
2953  ok(typeattr->cbSizeInstance == 8, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2954  ok(typeattr->typekind == TKIND_ALIAS, "typekind = %d\n", typeattr->typekind);
2955  ok(typeattr->cFuncs == 0, "cFuncs = %d\n", typeattr->cFuncs);
2956  ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2957  ok(typeattr->cImplTypes == 0, "cImplTypes = %d\n", typeattr->cImplTypes);
2958  ok(typeattr->cbSizeVft == 0, "cbSizeVft = %d\n", typeattr->cbSizeVft);
2959  ok(typeattr->cbAlignment == 4, "cbAlignment = %d\n", typeattr->cbAlignment);
2960  ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
2961  ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2962  ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2963  ok(typeattr->tdescAlias.vt == VT_R8, "Got wrong tdescAlias.vt: %u\n", typeattr->tdescAlias.vt);
2964  ITypeInfo_ReleaseTypeAttr(interface1, typeattr);
2965 
2966  ITypeInfo_Release(interface1);
2967  ICreateTypeInfo_Release(createti);
2968 
2969  hres = ICreateTypeLib2_SaveAllChanges(createtl);
2970  ok(hres == S_OK, "got %08x\n", hres);
2971 
2972  ok(ICreateTypeLib2_Release(createtl)==0, "Object should be freed\n");
2973 
2974  ok(ITypeInfo_Release(dispatch)==0, "Object should be freed\n");
2975  ok(ITypeInfo_Release(unknown)==0, "Object should be freed\n");
2976  ok(ITypeLib_Release(stdole)==0, "Object should be freed\n");
2977 
2979  ok(hres == S_OK, "got %08x\n", hres);
2980 
2981  hres = ITypeLib_GetLibAttr(tl, &libattr);
2982  ok(hres == S_OK, "got %08x\n", hres);
2983  ok(libattr->syskind == sys, "syskind = %d\n", libattr->syskind);
2984  ok(libattr->wMajorVerNum == 0, "wMajorVer = %d\n", libattr->wMajorVerNum);
2985  ok(libattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", libattr->wMinorVerNum);
2986  ok(libattr->wLibFlags == LIBFLAG_FHASDISKIMAGE, "wLibFlags = %d\n", libattr->wLibFlags);
2987  ITypeLib_ReleaseTLibAttr(tl, libattr);
2988 
2989  found = 2;
2990  memset(tinfos, 0, sizeof(tinfos));
2991  memids[0] = 0xdeadbeef;
2992  memids[1] = 0xdeadbeef;
2993  hres = ITypeLib_FindName(tl, param1W, 0, tinfos, memids, &found);
2994  ok(hres == S_OK, "got: %08x\n", hres);
2995  ok(found == 0, "got wrong count: %u\n", found);
2996  ok(tinfos[0] == NULL, "got invalid typeinfo[0]\n");
2997  ok(tinfos[1] == NULL, "got invalid typeinfo[1]\n");
2998  ok(memids[0] == 0xdeadbeef, "got invalid memid[0]\n");
2999  ok(memids[1] == 0xdeadbeef, "got invalid memid[1]\n");
3000 
3001  found = 2;
3002  memset(tinfos, 0, sizeof(tinfos));
3003  memids[0] = 0xdeadbeef;
3004  memids[1] = 0xdeadbeef;
3005  hres = ITypeLib_FindName(tl, func1W, 0, tinfos, memids, &found);
3006  ok(hres == S_OK, "got: %08x\n", hres);
3007  ok(found == 1, "got wrong count: %u\n", found);
3008  ok(tinfos[0] != NULL, "got invalid typeinfo[0]\n");
3009  ok(tinfos[1] == NULL, "got invalid typeinfo[1]\n");
3010  ok(memids[0] == 0, "got invalid memid[0]\n");
3011  ok(memids[1] == 0xdeadbeef, "got invalid memid[1]\n");
3012  if(tinfos[0])
3013  ITypeInfo_Release(tinfos[0]);
3014 
3015  found = 2;
3016  memset(tinfos, 0, sizeof(tinfos));
3017  memids[0] = 0xdeadbeef;
3018  memids[1] = 0xdeadbeef;
3019  hres = ITypeLib_FindName(tl, interface1W, 0, tinfos, memids, &found);
3020  ok(hres == S_OK, "got: %08x\n", hres);
3021  ok(found == 1, "got wrong count: %u\n", found);
3022  ok(tinfos[0] != NULL, "got invalid typeinfo[0]\n");
3023  ok(tinfos[1] == NULL, "got invalid typeinfo[1]\n");
3024  ok(memids[0] == MEMBERID_NIL, "got invalid memid[0]: %x\n", memids[0]);
3025  ok(memids[1] == 0xdeadbeef, "got invalid memid[1]\n");
3026  if(tinfos[0])
3027  ITypeInfo_Release(tinfos[0]);
3028 
3029  hres = ITypeLib_GetDocumentation(tl, -1, &name, &docstring, &helpcontext, &helpfile);
3030  ok(hres == S_OK, "got %08x\n", hres);
3031  ok(memcmp(typelibW, name, sizeof(typelibW)) == 0, "got wrong typelib name: %s\n",
3032  wine_dbgstr_w(name));
3033  ok(docstring == NULL, "got wrong docstring: %s\n", wine_dbgstr_w(docstring));
3034  ok(helpcontext == 0, "got wrong helpcontext: 0x%x\n", helpcontext);
3035  ok(memcmp(helpfileW, helpfile, sizeof(helpfileW)) == 0,
3036  "got wrong helpfile: %s\n", wine_dbgstr_w(helpfile));
3039 
3040  hres = ITypeLib_GetDocumentation(tl, 0, &name, &docstring, &helpcontext, &helpfile);
3041  ok(hres == S_OK, "got %08x\n", hres);
3042  ok(memcmp(interface1W, name, sizeof(interface1W)) == 0, "got wrong typeinfo name: %s\n",
3043  wine_dbgstr_w(name));
3044  ok(docstring == NULL, "got wrong docstring: %s\n", wine_dbgstr_w(docstring));
3045  ok(helpcontext == 0, "got wrong helpcontext: 0x%x\n", helpcontext);
3046  ok(memcmp(helpfileW, helpfile, sizeof(helpfileW)) == 0,
3047  "got wrong helpfile: %s\n", wine_dbgstr_w(helpfile));
3050 
3051  hres = ITypeLib_QueryInterface(tl, &IID_ITypeLib2, (void**)&tl2);
3052  ok(hres == S_OK, "no ITypeLib2 interface (%x)\n", hres);
3053  V_VT(&cust_data) = VT_EMPTY;
3054  V_I4(&cust_data) = 0;
3055  hres = ITypeLib2_GetCustData(tl2, &tlcustguid, &cust_data);
3056  ok(hres == S_OK, "got %08x\n", hres);
3057  ok(V_VT(&cust_data) == VT_I4, "V_VT(&cust_data) = %d\n", V_VT(&cust_data));
3058  ok(V_I4(&cust_data) == 1, "V_I4(&cust_data) = %d\n", V_I4(&cust_data));
3059  ITypeLib2_Release(tl2);
3060 
3061  hres = ITypeLib_GetTypeInfo(tl, 0, &ti);
3062  ok(hres == S_OK, "got %08x\n", hres);
3063 
3064  hres = ITypeInfo_GetTypeAttr(ti, &typeattr);
3065  ok(hres == S_OK, "got %08x\n", hres);
3066  ok(typeattr->cbSizeInstance == sizeof(void*), "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
3067  ok(typeattr->typekind == TKIND_INTERFACE, "typekind = %d\n", typeattr->typekind);
3068  ok(typeattr->cFuncs == 13, "cFuncs = %d\n", typeattr->cFuncs);
3069  ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
3070  ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
3071  todo_wine_if(is_win64 && sys == SYS_WIN32)
3072  ok(typeattr->cbSizeVft == 16 * sizeof(void*), "cbSizeVft = %d\n", typeattr->cbSizeVft);
3073  ok(typeattr->cbAlignment == alignment, "cbAlignment = %d\n", typeattr->cbAlignment);
3074  ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
3075  ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
3076  ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
3077  ITypeInfo_ReleaseTypeAttr(ti, typeattr);
3078 
3079  hres = ITypeInfo_GetRefTypeOfImplType(ti, 0, &hreftype);
3080  ok(hres == S_OK, "got %08x\n", hres);
3081  ok(hreftype == 3, "hreftype = %d\n", hreftype);
3082 
3083  hres = ITypeInfo_GetRefTypeInfo(ti, hreftype, &unknown);
3084  ok(hres == S_OK, "got %08x\n", hres);
3085 
3086  hres = ITypeInfo_GetTypeAttr(unknown, &typeattr);
3087  ok(hres == S_OK, "got %08x\n", hres);
3088  ok(IsEqualGUID(&typeattr->guid, &IID_IUnknown), "got wrong reftypeinfo\n");
3089  ITypeInfo_ReleaseTypeAttr(unknown, typeattr);
3090 
3091  ITypeInfo_Release(unknown);
3092 
3093  hres = ITypeInfo_GetFuncDesc(ti, 0, &pfuncdesc);
3094  ok(hres == S_OK, "got %08x\n", hres);
3095  ok(pfuncdesc->memid == 0, "got %x\n", pfuncdesc->memid);
3096  ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3097  ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3098  ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3099  ok(pfuncdesc->invkind == INVOKE_PROPERTYPUTREF, "got 0x%x\n", pfuncdesc->invkind);
3100  ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3101  ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
3102  ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3103  ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3104  ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3105  ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3106  edesc = pfuncdesc->lprgelemdescParam;
3107  ok(edesc->tdesc.vt == VT_BSTR, "got: %d\n", edesc->tdesc.vt);
3108  ok(U(*edesc).idldesc.wIDLFlags == IDLFLAG_FIN, "got: %x\n", U(*edesc).idldesc.wIDLFlags);
3109 
3110  hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3111  ok(hres == S_OK, "got: %08x\n", hres);
3112  ok(!memcmp(name, func1W, sizeof(func1W)), "got name: %s\n", wine_dbgstr_w(name));
3113  ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3114  ok(helpcontext == 0x201, "got helpcontext: 0x%x\n", helpcontext);
3115  ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3118 
3119  hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, NULL, 0, &cnames);
3120  ok(hres == E_INVALIDARG, "got: %08x\n", hres);
3121 
3122  cnames = 8;
3123  hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, 0, &cnames);
3124  ok(hres == S_OK, "got: %08x\n", hres);
3125  ok(cnames == 0, "got: %u\n", cnames);
3126 
3127  hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, sizeof(names) / sizeof(*names), &cnames);
3128  ok(hres == S_OK, "got: %08x\n", hres);
3129  ok(cnames == 1, "got: %u\n", cnames);
3130  ok(!memcmp(names[0], func1W, sizeof(func1W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
3131  SysFreeString(names[0]);
3132 
3133  ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3134 
3135  hres = ITypeInfo_GetFuncDesc(ti, 1, &pfuncdesc);
3136  ok(hres == S_OK, "got %08x\n", hres);
3137  ok(pfuncdesc->memid == 0x60010001, "got %x\n", pfuncdesc->memid);
3138  ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3139  ok(pfuncdesc->lprgelemdescParam == NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3140  ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3141  ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3142  ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3143  ok(pfuncdesc->cParams == 0, "got %d\n", pfuncdesc->cParams);
3144  ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3145  ok(pfuncdesc->oVft == 4 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3146  ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3147  ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3148  ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3149 
3150  hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3151  ok(hres == S_OK, "got: %08x\n", hres);
3152  ok(name == NULL, "got name: %s\n", wine_dbgstr_w(name));
3153  ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3154  ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
3155  ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3157  ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3158 
3159  hres = ITypeInfo_GetFuncDesc(ti, 2, &pfuncdesc);
3160  ok(hres == S_OK, "got %08x\n", hres);
3161  ok(pfuncdesc->memid == 0x1, "got %x\n", pfuncdesc->memid);
3162  ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3163  ok(pfuncdesc->lprgelemdescParam == NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3164  ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3165  ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3166  ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3167  ok(pfuncdesc->cParams == 0, "got %d\n", pfuncdesc->cParams);
3168  ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3169  ok(pfuncdesc->oVft == 5 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3170  ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3171  ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3172  ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3173 
3174  hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3175  ok(hres == S_OK, "got: %08x\n", hres);
3176  ok(name == NULL, "got name: %s\n", wine_dbgstr_w(name));
3177  ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3178  ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
3179  ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3181  ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3182 
3183  hres = ITypeInfo_GetFuncDesc(ti, 3, &pfuncdesc);
3184  ok(hres == S_OK, "got %08x\n", hres);
3185  ok(pfuncdesc->memid == 0x6001000b, "got %x\n", pfuncdesc->memid);
3186  ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3187  ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3188  ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3189  ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3190  ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3191  ok(pfuncdesc->cParams == 2, "got %d\n", pfuncdesc->cParams);
3192  ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3193  ok(pfuncdesc->oVft == 6 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3194  ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3195  ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3196  ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3197 
3198  edesc = pfuncdesc->lprgelemdescParam;
3199  ok(edesc->tdesc.vt == VT_BSTR, "got: %d\n", edesc->tdesc.vt);
3200  ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3201  ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3202  ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
3203  U(*edesc).paramdesc.pparamdescex->cBytes);
3204  ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_BSTR, "got: %d\n",
3205  V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3206  ok(!lstrcmpW(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue), nameW),
3207  "got: %s\n",
3208  wine_dbgstr_w(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue)));
3209 
3210  edesc = pfuncdesc->lprgelemdescParam + 1;
3211  ok(edesc->tdesc.vt == VT_BSTR, "got: %d\n", edesc->tdesc.vt);
3212  ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3213  ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3214  ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
3215  U(*edesc).paramdesc.pparamdescex->cBytes);
3216  ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_BSTR, "got: %d\n",
3217  V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3218  ok(!lstrcmpW(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue), nameW),
3219  "got: %s\n",
3220  wine_dbgstr_w(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue)));
3221 
3222  hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3223  ok(hres == S_OK, "got: %08x\n", hres);
3224  ok(!memcmp(name, func2W, sizeof(func2W)), "got name: %s\n", wine_dbgstr_w(name));
3225  ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3226  ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
3227  ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3230 
3231  hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, sizeof(names) / sizeof(*names), &cnames);
3232  ok(hres == S_OK, "got: %08x\n", hres);
3233  ok(cnames == 3, "got: %u\n", cnames);
3234  ok(!memcmp(names[0], func2W, sizeof(func2W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
3235  ok(!memcmp(names[1], param1W, sizeof(func2W)), "got names[1]: %s\n", wine_dbgstr_w(names[1]));
3236  ok(!memcmp(names[2], param2W, sizeof(func2W)), "got names[2]: %s\n", wine_dbgstr_w(names[2]));
3237  SysFreeString(names[0]);
3238  SysFreeString(names[1]);
3239  SysFreeString(names[2]);
3240  ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3241 
3242  hres = ITypeInfo_GetFuncDesc(ti, 4, &pfuncdesc);
3243  ok(hres == S_OK, "got %08x\n", hres);
3244  ok(pfuncdesc->memid == 0x6001000c, "got %x\n", pfuncdesc->memid);
3245  ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3246  ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3247  ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3248  ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3249  ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3250  ok(pfuncdesc->cParams == 2, "got %d\n", pfuncdesc->cParams);
3251  ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3252  ok(pfuncdesc->oVft == 7 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3253  ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3254  ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3255  ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3256 
3257  edesc = pfuncdesc->lprgelemdescParam;
3258  ok(edesc->tdesc.vt == VT_INT, "got: %d\n", edesc->tdesc.vt);
3259  ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3260  ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3261  ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
3262  U(*edesc).paramdesc.pparamdescex->cBytes);
3263  ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_I4, "got: %d\n",
3264  V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3265  ok(V_I4(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0xFFFFFFFF,
3266  "got: 0x%x\n", V_I4(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3267 
3268  edesc = pfuncdesc->lprgelemdescParam + 1;
3269  ok(edesc->tdesc.vt == VT_INT, "got: %d\n", edesc->tdesc.vt);
3270  ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3271  ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3272  ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
3273  U(*edesc).paramdesc.pparamdescex->cBytes);
3274  ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_I4, "got: %d\n",
3275  V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3276  ok(V_I4(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0xFFFFFFFF,
3277  "got: 0x%x\n", V_I4(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3278 
3279  hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3280  ok(hres == S_OK, "got: %08x\n", hres);
3281  ok(name == NULL, "got name: %s\n", wine_dbgstr_w(name));
3282  ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3283  ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
3284  ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3286  ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3287 
3288  hres = ITypeInfo_GetFuncDesc(ti, 5, &pfuncdesc);
3289  ok(hres == S_OK, "got %08x\n", hres);
3290  ok(pfuncdesc->memid == 0x60010005, "got %x\n", pfuncdesc->memid);
3291  ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3292  ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3293  ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3294  ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3295  ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3296  ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
3297  ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3298  ok(pfuncdesc->oVft == 8 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3299  ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3300  ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3301  ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3302 
3303  edesc = pfuncdesc->lprgelemdescParam;
3304  ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3305  ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
3306  U(*edesc).paramdesc.pparamdescex->cBytes);
3307  ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_INT, "got: %d\n",
3308  V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3309  ok(V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0x789, "got: 0x%x\n",
3310  V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3311  ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT,
3312  "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3313  ok(edesc->tdesc.vt == VT_USERDEFINED, "got: %d\n", edesc->tdesc.vt);
3314  ok(U(edesc->tdesc).hreftype == hreftype, "got: 0x%x\n", U(edesc->tdesc).hreftype);
3315 
3316  hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3317  ok(hres == S_OK, "got: %08x\n", hres);
3318  ok(name == NULL, "got name: %s\n", wine_dbgstr_w(name));
3319  ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3320  ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
3321  ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3323  ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3324 
3325  hres = ITypeInfo_GetFuncDesc(ti, 6, &pfuncdesc);
3326  ok(hres == S_OK, "got %08x\n", hres);
3327  ok(pfuncdesc->memid == 0x60010006, "got %x\n", pfuncdesc->memid);
3328  ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3329  ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3330  ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3331  ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3332  ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3333  ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
3334  ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3335  ok(pfuncdesc->oVft == 9 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3336  ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3337  ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VARIANT, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3338  ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3339 
3340  edesc = pfuncdesc->lprgelemdescParam;
3341  ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3342  ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
3343  U(*edesc).paramdesc.pparamdescex->cBytes);
3344  ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_INT, "got: %d\n",
3345  V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3346  ok(V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0x3, "got: 0x%x\n",
3347  V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3348  ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT,
3349  "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3350  ok(edesc->tdesc.vt == VT_VARIANT, "got: %d\n", edesc->tdesc.vt);
3351  ok(U(edesc->tdesc).hreftype == 0, "got: 0x%x\n", U(edesc->tdesc).hreftype);
3352 
3353  hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3354  ok(hres == S_OK, "got: %08x\n", hres);
3355  ok(name == NULL, "got name: %s\n", wine_dbgstr_w(name));
3356  ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3357  ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
3358  ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3360  ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3361 
3362  hres = ITypeInfo_GetFuncDesc(ti, 7, &pfuncdesc);
3363  ok(hres == S_OK, "got %08x\n", hres);
3364  ok(pfuncdesc->memid == 0x60010009, "got %x\n", pfuncdesc->memid);
3365  ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3366  ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3367  ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3368  ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3369  ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3370  ok(pfuncdesc->cParams == 2, "got %d\n", pfuncdesc->cParams);
3371  ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3372  ok(pfuncdesc->oVft == 10 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3373  ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3374  ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3375  ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3376 
3377  edesc = pfuncdesc->lprgelemdescParam;
3378  ok(edesc->tdesc.vt == VT_INT, "got: %d\n", edesc->tdesc.vt);
3379  ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FIN, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3380  ok(U(*edesc).paramdesc.pparamdescex == NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3381 
3382  edesc = pfuncdesc->lprgelemdescParam + 1;
3383  ok(edesc->tdesc.vt == VT_UI2, "got: %d\n", edesc->tdesc.vt);
3384  ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3385  ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3386  ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
3387  U(*edesc).paramdesc.pparamdescex->cBytes);
3388  ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_UI2, "got: %d\n",
3389  V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3390  ok(V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0xFFFF, "got: 0x%x\n",
3391  V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3392 
3393  hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3394  ok(hres == S_OK, "got: %08x\n", hres);
3395  ok(name == NULL, "got name: %s\n", wine_dbgstr_w(name));
3396  ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3397  ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
3398  ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3400  ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3401 
3402  hres = ITypeInfo_GetFuncDesc(ti, 8, &pfuncdesc);
3403  ok(hres == S_OK, "got %08x\n", hres);
3404  ok(pfuncdesc->memid == 0x60010003, "got %x\n", pfuncdesc->memid);
3405  ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3406  ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3407  ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3408  ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3409  ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3410  ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
3411  ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3412  ok(pfuncdesc->oVft == 11 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3413  ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3414  ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3415  ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3416 
3417  edesc = pfuncdesc->lprgelemdescParam;
3418  ok(edesc->tdesc.vt == VT_INT, "got: %d\n", edesc->tdesc.vt);
3419  ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3420  ok(U(*edesc).paramdesc.pparamdescex != NULL,