mshtml: Added IHTMLTableRow::align property implementation.
[wine.git] / dlls / oleaut32 / tests / typelib.c
bloba7e7c960f266ef72c648130bae1156a63e4e3a36
1 /*
2 * ITypeLib and ITypeInfo test
4 * Copyright 2004 Jacek Caban
5 * Copyright 2006 Dmitry Timoshkov
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define COBJMACROS
23 #define CONST_VTABLE
25 #include <wine/test.h>
26 #include <stdarg.h>
27 #include <stdio.h>
29 #include "windef.h"
30 #include "winbase.h"
31 #include "objbase.h"
32 #include "oleauto.h"
33 #include "ocidl.h"
34 #include "shlwapi.h"
35 #include "tmarshal.h"
37 #include "test_reg.h"
38 #include "test_tlb.h"
40 #define expect_eq(expr, value, type, format) { type _ret = (expr); ok((value) == _ret, #expr " expected " format " got " format "\n", value, _ret); }
41 #define expect_int(expr, value) expect_eq(expr, (int)(value), int, "%d")
42 #define expect_hex(expr, value) expect_eq(expr, (int)(value), int, "0x%x")
43 #define expect_null(expr) expect_eq(expr, NULL, const void *, "%p")
44 #define expect_guid(expected, guid) { ok(IsEqualGUID(expected, guid), "got wrong guid\n"); }
46 #define expect_wstr_acpval(expr, value) \
47 { \
48 CHAR buf[260]; \
49 expect_eq(!WideCharToMultiByte(CP_ACP, 0, (expr), -1, buf, 260, NULL, NULL), 0, int, "%d"); \
50 ok(strcmp(value, buf) == 0, #expr " expected \"%s\" got \"%s\"\n", value, buf); \
53 #define ole_expect(expr, expect) { \
54 HRESULT r = expr; \
55 ok(r == (expect), #expr " returned %x, expected %s (%x)\n", r, #expect, expect); \
58 #define ole_check(expr) ole_expect(expr, S_OK);
60 #define ok_ole_success(hr, func) ok(hr == S_OK, #func " failed with error 0x%08x\n", hr)
62 #ifdef __i386__
63 #define ARCH "x86"
64 #elif defined __x86_64__
65 #define ARCH "amd64"
66 #else
67 #define ARCH "none"
68 #endif
70 static HRESULT WINAPI (*pRegisterTypeLibForUser)(ITypeLib*,OLECHAR*,OLECHAR*);
71 static HRESULT WINAPI (*pUnRegisterTypeLibForUser)(REFGUID,WORD,WORD,LCID,SYSKIND);
73 static BOOL (WINAPI *pActivateActCtx)(HANDLE,ULONG_PTR*);
74 static HANDLE (WINAPI *pCreateActCtxW)(PCACTCTXW);
75 static BOOL (WINAPI *pDeactivateActCtx)(DWORD,ULONG_PTR);
76 static VOID (WINAPI *pReleaseActCtx)(HANDLE);
78 static const WCHAR wszStdOle2[] = {'s','t','d','o','l','e','2','.','t','l','b',0};
79 static WCHAR wszGUID[] = {'G','U','I','D',0};
80 static WCHAR wszguid[] = {'g','u','i','d',0};
82 static const BOOL is_win64 = sizeof(void *) > sizeof(int);
84 static HRESULT WINAPI invoketest_QueryInterface(IInvokeTest *iface, REFIID riid, void **ret)
86 if (IsEqualIID(riid, &IID_IUnknown) ||
87 IsEqualIID(riid, &IID_IDispatch) ||
88 IsEqualIID(riid, &IID_IInvokeTest))
90 *ret = iface;
91 return S_OK;
94 return E_NOINTERFACE;
97 static ULONG WINAPI invoketest_AddRef(IInvokeTest *iface)
99 return 2;
102 static ULONG WINAPI invoketest_Release(IInvokeTest *iface)
104 return 1;
107 static HRESULT WINAPI invoketest_GetTypeInfoCount(IInvokeTest *iface, UINT *cnt)
109 ok(0, "unexpected call\n");
110 *cnt = 0;
111 return E_NOTIMPL;
114 static HRESULT WINAPI invoketest_GetTypeInfo(IInvokeTest *iface, UINT index, LCID lcid, ITypeInfo **ti)
116 ok(0, "unexpected call\n");
117 return E_NOTIMPL;
120 static HRESULT WINAPI invoketest_GetIDsOfNames(IInvokeTest *iface, REFIID riid, LPOLESTR *names,
121 UINT cnt, LCID lcid, DISPID *dispid)
123 ok(0, "unexpected call\n");
124 return E_NOTIMPL;
127 static HRESULT WINAPI invoketest_Invoke(IInvokeTest *iface, DISPID dispid, REFIID riid,
128 LCID lcid, WORD flags, DISPPARAMS *dispparams, VARIANT *res, EXCEPINFO *ei, UINT *argerr)
130 ok(0, "unexpected call\n");
131 return E_NOTIMPL;
134 static LONG WINAPI invoketest_get_test(IInvokeTest *iface, LONG i)
136 return i+1;
139 static LONG WINAPI invoketest_putref_testprop(IInvokeTest *iface, LONG *i)
141 return *i+2;
144 static LONG WINAPI invoketest_putref_testprop2(IInvokeTest *iface, IUnknown *i)
146 return 6;
149 static const IInvokeTestVtbl invoketestvtbl = {
150 invoketest_QueryInterface,
151 invoketest_AddRef,
152 invoketest_Release,
153 invoketest_GetTypeInfoCount,
154 invoketest_GetTypeInfo,
155 invoketest_GetIDsOfNames,
156 invoketest_Invoke,
157 invoketest_get_test,
158 invoketest_putref_testprop,
159 invoketest_putref_testprop2
162 static IInvokeTest invoketest = { &invoketestvtbl };
164 static void init_function_pointers(void)
166 HMODULE hmod = GetModuleHandleA("oleaut32.dll");
167 HMODULE hk32 = GetModuleHandleA("kernel32.dll");
169 pRegisterTypeLibForUser = (void *)GetProcAddress(hmod, "RegisterTypeLibForUser");
170 pUnRegisterTypeLibForUser = (void *)GetProcAddress(hmod, "UnRegisterTypeLibForUser");
171 pActivateActCtx = (void *)GetProcAddress(hk32, "ActivateActCtx");
172 pCreateActCtxW = (void *)GetProcAddress(hk32, "CreateActCtxW");
173 pDeactivateActCtx = (void *)GetProcAddress(hk32, "DeactivateActCtx");
174 pReleaseActCtx = (void *)GetProcAddress(hk32, "ReleaseActCtx");
177 static void ref_count_test(LPCWSTR type_lib)
179 ITypeLib *iface;
180 ITypeInfo *iti1, *iti2;
181 HRESULT hRes;
182 int ref_count;
184 trace("Loading type library\n");
185 hRes = LoadTypeLib(type_lib, &iface);
186 ok(hRes == S_OK, "Could not load type library\n");
187 if(hRes != S_OK)
188 return;
190 hRes = ITypeLib_GetTypeInfo(iface, 1, &iti1);
191 ok(hRes == S_OK, "ITypeLib_GetTypeInfo failed on index = 1\n");
192 ok(ref_count=ITypeLib_Release(iface) > 0, "ITypeLib destroyed while ITypeInfo has back pointer\n");
193 if(!ref_count)
194 return;
196 hRes = ITypeLib_GetTypeInfo(iface, 1, &iti2);
197 ok(hRes == S_OK, "ITypeLib_GetTypeInfo failed on index = 1\n");
198 ok(iti1 == iti2, "ITypeLib_GetTypeInfo returned different pointers for same indexes\n");
200 ITypeLib_AddRef(iface);
201 ITypeInfo_Release(iti2);
202 ITypeInfo_Release(iti1);
203 ok(ITypeLib_Release(iface) == 0, "ITypeLib should be destroyed here.\n");
206 static void test_TypeComp(void)
208 ITypeLib *pTypeLib;
209 ITypeComp *pTypeComp;
210 HRESULT hr;
211 ULONG ulHash;
212 DESCKIND desckind;
213 BINDPTR bindptr;
214 ITypeInfo *pTypeInfo;
215 ITypeInfo *pFontTypeInfo;
216 ITypeComp *pTypeComp_tmp;
217 static WCHAR wszStdFunctions[] = {'S','t','d','F','u','n','c','t','i','o','n','s',0};
218 static WCHAR wszSavePicture[] = {'S','a','v','e','P','i','c','t','u','r','e',0};
219 static WCHAR wszOLE_TRISTATE[] = {'O','L','E','_','T','R','I','S','T','A','T','E',0};
220 static WCHAR wszUnchecked[] = {'U','n','c','h','e','c','k','e','d',0};
221 static WCHAR wszIUnknown[] = {'I','U','n','k','n','o','w','n',0};
222 static WCHAR wszFont[] = {'F','o','n','t',0};
223 static WCHAR wszStdPicture[] = {'S','t','d','P','i','c','t','u','r','e',0};
224 static WCHAR wszOLE_COLOR[] = {'O','L','E','_','C','O','L','O','R',0};
225 static WCHAR wszClone[] = {'C','l','o','n','e',0};
226 static WCHAR wszclone[] = {'c','l','o','n','e',0};
227 static WCHAR wszJunk[] = {'J','u','n','k',0};
228 static WCHAR wszAddRef[] = {'A','d','d','R','e','f',0};
230 hr = LoadTypeLib(wszStdOle2, &pTypeLib);
231 ok_ole_success(hr, LoadTypeLib);
233 hr = ITypeLib_GetTypeComp(pTypeLib, &pTypeComp);
234 ok_ole_success(hr, ITypeLib_GetTypeComp);
236 /* test getting a TKIND_MODULE */
237 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszStdFunctions);
238 hr = ITypeComp_Bind(pTypeComp, wszStdFunctions, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
239 ok_ole_success(hr, ITypeComp_Bind);
241 ok(desckind == DESCKIND_TYPECOMP,
242 "desckind should have been DESCKIND_TYPECOMP instead of %d\n",
243 desckind);
244 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
246 ITypeComp_Release(bindptr.lptcomp);
248 /* test getting a TKIND_MODULE with INVOKE_PROPERTYGET */
249 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszStdFunctions);
250 hr = ITypeComp_Bind(pTypeComp, wszStdFunctions, ulHash, INVOKE_PROPERTYGET, &pTypeInfo, &desckind, &bindptr);
251 ok_ole_success(hr, ITypeComp_Bind);
253 ok(desckind == DESCKIND_TYPECOMP,
254 "desckind should have been DESCKIND_TYPECOMP instead of %d\n",
255 desckind);
256 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
257 ITypeComp_Release(bindptr.lptcomp);
259 /* test getting a function within a TKIND_MODULE */
260 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszSavePicture);
261 hr = ITypeComp_Bind(pTypeComp, wszSavePicture, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
262 ok_ole_success(hr, ITypeComp_Bind);
264 ok(desckind == DESCKIND_FUNCDESC,
265 "desckind should have been DESCKIND_FUNCDESC instead of %d\n",
266 desckind);
267 ok(bindptr.lpfuncdesc != NULL, "bindptr.lpfuncdesc should not have been set to NULL\n");
268 ITypeInfo_ReleaseFuncDesc(pTypeInfo, bindptr.lpfuncdesc);
269 ITypeInfo_Release(pTypeInfo);
271 /* test getting a function within a TKIND_MODULE with INVOKE_PROPERTYGET */
272 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszSavePicture);
273 hr = ITypeComp_Bind(pTypeComp, wszSavePicture, ulHash, INVOKE_PROPERTYGET, &pTypeInfo, &desckind, &bindptr);
274 ok(hr == TYPE_E_TYPEMISMATCH,
275 "ITypeComp_Bind should have failed with TYPE_E_TYPEMISMATCH instead of 0x%08x\n",
276 hr);
278 ok(desckind == DESCKIND_NONE,
279 "desckind should have been DESCKIND_NONE instead of %d\n",
280 desckind);
281 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
282 ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
284 /* test getting a TKIND_ENUM */
285 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszOLE_TRISTATE);
286 hr = ITypeComp_Bind(pTypeComp, wszOLE_TRISTATE, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
287 ok_ole_success(hr, ITypeComp_Bind);
289 ok(desckind == DESCKIND_TYPECOMP,
290 "desckind should have been DESCKIND_TYPECOMP instead of %d\n",
291 desckind);
292 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
294 ITypeComp_Release(bindptr.lptcomp);
296 /* test getting a value within a TKIND_ENUM */
297 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszUnchecked);
298 hr = ITypeComp_Bind(pTypeComp, wszUnchecked, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
299 ok_ole_success(hr, ITypeComp_Bind);
301 ok(desckind == DESCKIND_VARDESC,
302 "desckind should have been DESCKIND_VARDESC instead of %d\n",
303 desckind);
304 ITypeInfo_ReleaseVarDesc(pTypeInfo, bindptr.lpvardesc);
305 ITypeInfo_Release(pTypeInfo);
307 /* test getting a TKIND_INTERFACE */
308 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszIUnknown);
309 hr = ITypeComp_Bind(pTypeComp, wszIUnknown, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
310 ok_ole_success(hr, ITypeComp_Bind);
312 ok(desckind == DESCKIND_NONE,
313 "desckind should have been DESCKIND_NONE instead of %d\n",
314 desckind);
315 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
316 ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
318 /* test getting a TKIND_DISPATCH */
319 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszFont);
320 hr = ITypeComp_Bind(pTypeComp, wszFont, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
321 ok_ole_success(hr, ITypeComp_Bind);
323 ok(desckind == DESCKIND_NONE,
324 "desckind should have been DESCKIND_NONE instead of %d\n",
325 desckind);
326 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
327 ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
329 /* test getting a TKIND_RECORD/TKIND_ALIAS */
330 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszGUID);
331 hr = ITypeComp_Bind(pTypeComp, wszGUID, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
332 ok_ole_success(hr, ITypeComp_Bind);
334 ok(desckind == DESCKIND_NONE,
335 "desckind should have been DESCKIND_NONE instead of %d\n",
336 desckind);
337 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
338 ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
340 /* test getting a TKIND_ALIAS */
341 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszOLE_COLOR);
342 hr = ITypeComp_Bind(pTypeComp, wszOLE_COLOR, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
343 ok_ole_success(hr, ITypeComp_Bind);
345 ok(desckind == DESCKIND_NONE,
346 "desckind should have been DESCKIND_NONE instead of %d\n",
347 desckind);
348 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
349 ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
351 /* test getting a TKIND_COCLASS */
352 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszStdPicture);
353 hr = ITypeComp_Bind(pTypeComp, wszStdPicture, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
354 ok_ole_success(hr, ITypeComp_Bind);
356 ok(desckind == DESCKIND_NONE,
357 "desckind should have been DESCKIND_NONE instead of %d\n",
358 desckind);
359 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
360 ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
362 /* test basic BindType argument handling */
363 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszGUID);
364 hr = ITypeComp_BindType(pTypeComp, wszGUID, ulHash, NULL, NULL);
365 ok(hr == E_INVALIDARG, "Got %08x\n", hr);
367 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszGUID);
368 pTypeInfo = (void*)0xdeadbeef;
369 hr = ITypeComp_BindType(pTypeComp, wszGUID, ulHash, &pTypeInfo, NULL);
370 ok(hr == E_INVALIDARG, "Got %08x\n", hr);
371 ok(pTypeInfo == (void*)0xdeadbeef, "Got %p\n", pTypeInfo);
373 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszGUID);
374 pTypeComp_tmp = (void*)0xdeadbeef;
375 hr = ITypeComp_BindType(pTypeComp, wszGUID, ulHash, NULL, &pTypeComp_tmp);
376 ok(hr == E_INVALIDARG, "Got %08x\n", hr);
377 ok(pTypeComp_tmp == (void*)0xdeadbeef, "Got %p\n", pTypeComp_tmp);
379 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszGUID);
380 pTypeComp_tmp = (void*)0xdeadbeef;
381 pTypeInfo = (void*)0xdeadbeef;
382 hr = ITypeComp_BindType(pTypeComp, NULL, ulHash, &pTypeInfo, &pTypeComp_tmp);
383 ok(hr == E_INVALIDARG, "Got %08x\n", hr);
384 ok(pTypeInfo == (void*)0xdeadbeef, "Got %p\n", pTypeInfo);
385 ok(pTypeComp_tmp == (void*)0xdeadbeef, "Got %p\n", pTypeComp_tmp);
387 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszGUID);
388 pTypeComp_tmp = (void*)0xdeadbeef;
389 pTypeInfo = (void*)0xdeadbeef;
390 hr = ITypeComp_BindType(pTypeComp, wszGUID, ulHash, &pTypeInfo, &pTypeComp_tmp);
391 ok_ole_success(hr, ITypeComp_BindType);
392 ok(pTypeInfo != NULL, "Got NULL pTypeInfo\n");
393 todo_wine ok(pTypeComp_tmp == NULL, "Got pTypeComp_tmp %p\n", pTypeComp_tmp);
394 ITypeInfo_Release(pTypeInfo);
395 if(pTypeComp_tmp) ITypeComp_Release(pTypeComp_tmp); /* fixme */
397 /* test BindType case-insensitivity */
398 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszguid);
399 pTypeComp_tmp = (void*)0xdeadbeef;
400 pTypeInfo = (void*)0xdeadbeef;
401 hr = ITypeComp_BindType(pTypeComp, wszguid, ulHash, &pTypeInfo, &pTypeComp_tmp);
402 ok_ole_success(hr, ITypeComp_BindType);
403 ok(pTypeInfo != NULL, "Got NULL pTypeInfo\n");
404 todo_wine ok(pTypeComp_tmp == NULL, "Got pTypeComp_tmp %p\n", pTypeComp_tmp);
405 ITypeInfo_Release(pTypeInfo);
406 if(pTypeComp_tmp) ITypeComp_Release(pTypeComp_tmp); /* fixme */
408 ITypeComp_Release(pTypeComp);
410 /* tests for ITypeComp on an interface */
411 hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, &IID_IFont, &pFontTypeInfo);
412 ok_ole_success(hr, ITypeLib_GetTypeInfoOfGuid);
414 hr = ITypeInfo_GetTypeComp(pFontTypeInfo, &pTypeComp);
415 ok_ole_success(hr, ITypeLib_GetTypeComp);
417 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszClone);
418 hr = ITypeComp_Bind(pTypeComp, wszClone, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
419 ok_ole_success(hr, ITypeComp_Bind);
421 ok(desckind == DESCKIND_FUNCDESC,
422 "desckind should have been DESCKIND_FUNCDESC instead of %d\n",
423 desckind);
424 ok(bindptr.lpfuncdesc != NULL, "bindptr.lpfuncdesc should not have been set to NULL\n");
425 ITypeInfo_ReleaseFuncDesc(pTypeInfo, bindptr.lpfuncdesc);
426 ITypeInfo_Release(pTypeInfo);
428 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszClone);
429 hr = ITypeComp_Bind(pTypeComp, wszClone, ulHash, INVOKE_PROPERTYGET, &pTypeInfo, &desckind, &bindptr);
430 ok(hr == TYPE_E_TYPEMISMATCH, "ITypeComp_Bind should have failed with TYPE_E_TYPEMISMATCH instead of 0x%08x\n", hr);
432 ok(desckind == DESCKIND_NONE,
433 "desckind should have been DESCKIND_NONE instead of %d\n",
434 desckind);
435 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
436 ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
438 /* tests that the compare is case-insensitive */
439 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszclone);
440 hr = ITypeComp_Bind(pTypeComp, wszclone, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
441 ok_ole_success(hr, ITypeComp_Bind);
443 ok(desckind == DESCKIND_FUNCDESC,
444 "desckind should have been DESCKIND_FUNCDESC instead of %d\n",
445 desckind);
446 ok(bindptr.lpfuncdesc != NULL, "bindptr.lpfuncdesc should not have been set to NULL\n");
447 ITypeInfo_ReleaseFuncDesc(pTypeInfo, bindptr.lpfuncdesc);
448 ITypeInfo_Release(pTypeInfo);
450 /* tests nonexistent members */
451 desckind = 0xdeadbeef;
452 bindptr.lptcomp = (ITypeComp*)0xdeadbeef;
453 pTypeInfo = (ITypeInfo*)0xdeadbeef;
454 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszJunk);
455 hr = ITypeComp_Bind(pTypeComp, wszJunk, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
456 ok_ole_success(hr, ITypeComp_Bind);
457 ok(desckind == DESCKIND_NONE, "desckind should have been DESCKIND_NONE, was: %d\n", desckind);
458 ok(pTypeInfo == NULL, "pTypeInfo should have been NULL, was: %p\n", pTypeInfo);
459 ok(bindptr.lptcomp == NULL, "bindptr should have been NULL, was: %p\n", bindptr.lptcomp);
461 /* tests inherited members */
462 desckind = 0xdeadbeef;
463 bindptr.lpfuncdesc = NULL;
464 pTypeInfo = NULL;
465 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszAddRef);
466 hr = ITypeComp_Bind(pTypeComp, wszAddRef, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
467 ok_ole_success(hr, ITypeComp_Bind);
468 ok(desckind == DESCKIND_FUNCDESC, "desckind should have been DESCKIND_FUNCDESC, was: %d\n", desckind);
469 ok(pTypeInfo != NULL, "pTypeInfo should not have been NULL, was: %p\n", pTypeInfo);
470 ok(bindptr.lpfuncdesc != NULL, "bindptr should not have been NULL, was: %p\n", bindptr.lpfuncdesc);
471 ITypeInfo_ReleaseFuncDesc(pTypeInfo, bindptr.lpfuncdesc);
472 ITypeInfo_Release(pTypeInfo);
474 ITypeComp_Release(pTypeComp);
475 ITypeInfo_Release(pFontTypeInfo);
476 ITypeLib_Release(pTypeLib);
479 static void test_CreateDispTypeInfo(void)
481 ITypeInfo *pTypeInfo, *pTI2;
482 HRESULT hr;
483 INTERFACEDATA ifdata;
484 METHODDATA methdata[4];
485 PARAMDATA parms1[2];
486 PARAMDATA parms3[1];
487 TYPEATTR *pTypeAttr;
488 HREFTYPE href;
489 FUNCDESC *pFuncDesc;
490 MEMBERID memid;
492 static WCHAR func1[] = {'f','u','n','c','1',0};
493 static const WCHAR func2[] = {'f','u','n','c','2',0};
494 static const WCHAR func3[] = {'f','u','n','c','3',0};
495 static const WCHAR parm1[] = {'p','a','r','m','1',0};
496 static const WCHAR parm2[] = {'p','a','r','m','2',0};
497 OLECHAR *name = func1;
499 ifdata.pmethdata = methdata;
500 ifdata.cMembers = sizeof(methdata) / sizeof(methdata[0]);
502 methdata[0].szName = SysAllocString(func1);
503 methdata[0].ppdata = parms1;
504 methdata[0].dispid = 0x123;
505 methdata[0].iMeth = 0;
506 methdata[0].cc = CC_STDCALL;
507 methdata[0].cArgs = 2;
508 methdata[0].wFlags = DISPATCH_METHOD;
509 methdata[0].vtReturn = VT_HRESULT;
510 parms1[0].szName = SysAllocString(parm1);
511 parms1[0].vt = VT_I4;
512 parms1[1].szName = SysAllocString(parm2);
513 parms1[1].vt = VT_BSTR;
515 methdata[1].szName = SysAllocString(func2);
516 methdata[1].ppdata = NULL;
517 methdata[1].dispid = 0x124;
518 methdata[1].iMeth = 1;
519 methdata[1].cc = CC_STDCALL;
520 methdata[1].cArgs = 0;
521 methdata[1].wFlags = DISPATCH_PROPERTYGET;
522 methdata[1].vtReturn = VT_I4;
524 methdata[2].szName = SysAllocString(func3);
525 methdata[2].ppdata = parms3;
526 methdata[2].dispid = 0x125;
527 methdata[2].iMeth = 3;
528 methdata[2].cc = CC_STDCALL;
529 methdata[2].cArgs = 1;
530 methdata[2].wFlags = DISPATCH_PROPERTYPUT;
531 methdata[2].vtReturn = VT_HRESULT;
532 parms3[0].szName = SysAllocString(parm1);
533 parms3[0].vt = VT_I4;
535 methdata[3].szName = SysAllocString(func3);
536 methdata[3].ppdata = NULL;
537 methdata[3].dispid = 0x125;
538 methdata[3].iMeth = 4;
539 methdata[3].cc = CC_STDCALL;
540 methdata[3].cArgs = 0;
541 methdata[3].wFlags = DISPATCH_PROPERTYGET;
542 methdata[3].vtReturn = VT_I4;
544 hr = CreateDispTypeInfo(&ifdata, LOCALE_NEUTRAL, &pTypeInfo);
545 ok(hr == S_OK, "hr %08x\n", hr);
547 hr = ITypeInfo_GetTypeAttr(pTypeInfo, &pTypeAttr);
548 ok(hr == S_OK, "hr %08x\n", hr);
550 ok(pTypeAttr->typekind == TKIND_COCLASS, "typekind %0x\n", pTypeAttr->typekind);
551 ok(pTypeAttr->cImplTypes == 1, "cImplTypes %d\n", pTypeAttr->cImplTypes);
552 ok(pTypeAttr->cFuncs == 0, "cFuncs %d\n", pTypeAttr->cFuncs);
553 ok(pTypeAttr->wTypeFlags == 0, "wTypeFlags %04x\n", pTypeAttr->cFuncs);
554 ITypeInfo_ReleaseTypeAttr(pTypeInfo, pTypeAttr);
556 hr = ITypeInfo_GetRefTypeOfImplType(pTypeInfo, 0, &href);
557 ok(hr == S_OK, "hr %08x\n", hr);
558 ok(href == 0, "href = 0x%x\n", href);
559 hr = ITypeInfo_GetRefTypeInfo(pTypeInfo, href, &pTI2);
560 ok(hr == S_OK, "hr %08x\n", hr);
561 hr = ITypeInfo_GetTypeAttr(pTI2, &pTypeAttr);
562 ok(hr == S_OK, "hr %08x\n", hr);
563 ok(pTypeAttr->typekind == TKIND_INTERFACE, "typekind %0x\n", pTypeAttr->typekind);
564 ok(pTypeAttr->cFuncs == 4, "cFuncs %d\n", pTypeAttr->cFuncs);
565 ok(IsEqualGUID(&pTypeAttr->guid, &GUID_NULL), "guid {%08x-...}\n", pTypeAttr->guid.Data1);
566 ok(pTypeAttr->wTypeFlags == 0, "typeflags %08x\n", pTypeAttr->wTypeFlags);
568 ITypeInfo_ReleaseTypeAttr(pTI2, pTypeAttr);
570 hr = ITypeInfo_GetFuncDesc(pTI2, 0, &pFuncDesc);
571 ok(hr == S_OK, "hr %08x\n", hr);
572 ok(pFuncDesc->memid == 0x123, "memid %x\n", pFuncDesc->memid);
573 ok(pFuncDesc->funckind == FUNC_VIRTUAL, "funckind %d\n", pFuncDesc->funckind);
574 ok(pFuncDesc->invkind == methdata[0].wFlags, "invkind %d\n", pFuncDesc->invkind);
575 ok(pFuncDesc->callconv == methdata[0].cc, "callconv %d\n", pFuncDesc->callconv);
576 ok(pFuncDesc->cParams == methdata[0].cArgs, "cParams %d\n", pFuncDesc->cParams);
577 ok(pFuncDesc->oVft == 0, "oVft %d\n", pFuncDesc->oVft);
578 ok(pFuncDesc->wFuncFlags == 0, "oVft %d\n", pFuncDesc->wFuncFlags);
579 ok(pFuncDesc->elemdescFunc.tdesc.vt == VT_HRESULT, "ret vt %x\n", pFuncDesc->elemdescFunc.tdesc.vt);
580 ok(pFuncDesc->lprgelemdescParam[0].tdesc.vt == VT_I4, "parm 0 vt %x\n", pFuncDesc->lprgelemdescParam[0].tdesc.vt);
581 ok(U(pFuncDesc->lprgelemdescParam[0]).paramdesc.wParamFlags == PARAMFLAG_NONE, "parm 0 flags %x\n", U(pFuncDesc->lprgelemdescParam[0]).paramdesc.wParamFlags);
583 ok(pFuncDesc->lprgelemdescParam[1].tdesc.vt == VT_BSTR, "parm 1 vt %x\n", pFuncDesc->lprgelemdescParam[1].tdesc.vt);
584 ok(U(pFuncDesc->lprgelemdescParam[1]).paramdesc.wParamFlags == PARAMFLAG_NONE, "parm 1 flags %x\n", U(pFuncDesc->lprgelemdescParam[1]).paramdesc.wParamFlags);
585 ITypeInfo_ReleaseFuncDesc(pTI2, pFuncDesc);
587 hr = ITypeInfo_GetFuncDesc(pTI2, 1, &pFuncDesc);
588 ok(hr == S_OK, "hr %08x\n", hr);
589 ok(pFuncDesc->funckind == FUNC_VIRTUAL, "funckind %d\n", pFuncDesc->funckind);
590 ok(pFuncDesc->invkind == methdata[1].wFlags, "invkind %d\n", pFuncDesc->invkind);
591 ok(pFuncDesc->callconv == methdata[1].cc, "callconv %d\n", pFuncDesc->callconv);
592 ok(pFuncDesc->cParams == methdata[1].cArgs, "cParams %d\n", pFuncDesc->cParams);
593 ok(pFuncDesc->oVft == sizeof(void *), "oVft %d\n", pFuncDesc->oVft);
594 ok(pFuncDesc->wFuncFlags == 0, "oVft %d\n", pFuncDesc->wFuncFlags);
595 ok(pFuncDesc->elemdescFunc.tdesc.vt == VT_I4, "ret vt %x\n", pFuncDesc->elemdescFunc.tdesc.vt);
596 ITypeInfo_ReleaseFuncDesc(pTI2, pFuncDesc);
598 hr = ITypeInfo_GetFuncDesc(pTI2, 2, &pFuncDesc);
599 ok(hr == S_OK, "hr %08x\n", hr);
600 ok(pFuncDesc->funckind == FUNC_VIRTUAL, "funckind %d\n", pFuncDesc->funckind);
601 ok(pFuncDesc->invkind == methdata[2].wFlags, "invkind %d\n", pFuncDesc->invkind);
602 ok(pFuncDesc->callconv == methdata[2].cc, "callconv %d\n", pFuncDesc->callconv);
603 ok(pFuncDesc->cParams == methdata[2].cArgs, "cParams %d\n", pFuncDesc->cParams);
604 ok(pFuncDesc->oVft == 3 * sizeof(void *), "oVft %d\n", pFuncDesc->oVft);
605 ok(pFuncDesc->wFuncFlags == 0, "oVft %d\n", pFuncDesc->wFuncFlags);
606 ok(pFuncDesc->elemdescFunc.tdesc.vt == VT_HRESULT, "ret vt %x\n", pFuncDesc->elemdescFunc.tdesc.vt);
607 ok(pFuncDesc->lprgelemdescParam[0].tdesc.vt == VT_I4, "parm 0 vt %x\n", pFuncDesc->lprgelemdescParam[0].tdesc.vt);
608 ok(U(pFuncDesc->lprgelemdescParam[0]).paramdesc.wParamFlags == PARAMFLAG_NONE, "parm 0 flags %x\n", U(pFuncDesc->lprgelemdescParam[0]).paramdesc.wParamFlags);
609 ITypeInfo_ReleaseFuncDesc(pTI2, pFuncDesc);
611 hr = ITypeInfo_GetFuncDesc(pTI2, 3, &pFuncDesc);
612 ok(hr == S_OK, "hr %08x\n", hr);
613 ok(pFuncDesc->funckind == FUNC_VIRTUAL, "funckind %d\n", pFuncDesc->funckind);
614 ok(pFuncDesc->invkind == methdata[3].wFlags, "invkind %d\n", pFuncDesc->invkind);
615 ok(pFuncDesc->callconv == methdata[3].cc, "callconv %d\n", pFuncDesc->callconv);
616 ok(pFuncDesc->cParams == methdata[3].cArgs, "cParams %d\n", pFuncDesc->cParams);
617 ok(pFuncDesc->oVft == 4 * sizeof(void *), "oVft %d\n", pFuncDesc->oVft);
618 ok(pFuncDesc->wFuncFlags == 0, "oVft %d\n", pFuncDesc->wFuncFlags);
619 ok(pFuncDesc->elemdescFunc.tdesc.vt == VT_I4, "ret vt %x\n", pFuncDesc->elemdescFunc.tdesc.vt);
620 ITypeInfo_ReleaseFuncDesc(pTI2, pFuncDesc);
622 /* test GetIDsOfNames on a coclass to see if it searches its interfaces */
623 hr = ITypeInfo_GetIDsOfNames(pTypeInfo, &name, 1, &memid);
624 ok(hr == S_OK, "hr 0x%08x\n", hr);
625 ok(memid == 0x123, "memid 0x%08x\n", memid);
627 ITypeInfo_Release(pTI2);
628 ITypeInfo_Release(pTypeInfo);
630 SysFreeString(parms1[0].szName);
631 SysFreeString(parms1[1].szName);
632 SysFreeString(parms3[0].szName);
633 SysFreeString(methdata[0].szName);
634 SysFreeString(methdata[1].szName);
635 SysFreeString(methdata[2].szName);
636 SysFreeString(methdata[3].szName);
639 static void write_typelib(int res_no, const char *filename)
641 DWORD written;
642 HANDLE file;
643 HRSRC res;
644 void *ptr;
646 file = CreateFileA( filename, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0 );
647 ok( file != INVALID_HANDLE_VALUE, "file creation failed\n" );
648 if (file == INVALID_HANDLE_VALUE) return;
649 res = FindResourceA( GetModuleHandleA(NULL), (LPCSTR)MAKEINTRESOURCE(res_no), "TYPELIB" );
650 ok( res != 0, "couldn't find resource\n" );
651 ptr = LockResource( LoadResource( GetModuleHandleA(NULL), res ));
652 WriteFile( file, ptr, SizeofResource( GetModuleHandleA(NULL), res ), &written, NULL );
653 ok( written == SizeofResource( GetModuleHandleA(NULL), res ), "couldn't write resource\n" );
654 CloseHandle( file );
657 static const char *create_test_typelib(int res_no)
659 static char filename[MAX_PATH];
661 GetTempFileNameA( ".", "tlb", 0, filename );
662 write_typelib(res_no, filename);
663 return filename;
666 static void test_TypeInfo(void)
668 ITypeLib *pTypeLib;
669 ITypeInfo *pTypeInfo, *ti;
670 ITypeInfo2 *pTypeInfo2;
671 HRESULT hr;
672 static WCHAR wszBogus[] = { 'b','o','g','u','s',0 };
673 static WCHAR wszGetTypeInfo[] = { 'G','e','t','T','y','p','e','I','n','f','o',0 };
674 static WCHAR wszClone[] = {'C','l','o','n','e',0};
675 OLECHAR* bogus = wszBogus;
676 OLECHAR* pwszGetTypeInfo = wszGetTypeInfo;
677 OLECHAR* pwszClone = wszClone;
678 DISPID dispidMember;
679 DISPPARAMS dispparams;
680 GUID bogusguid = {0x806afb4f,0x13f7,0x42d2,{0x89,0x2c,0x6c,0x97,0xc3,0x6a,0x36,0xc1}};
681 VARIANT var, res, args[2];
682 UINT count, i;
683 TYPEKIND kind;
684 const char *filenameA;
685 WCHAR filename[MAX_PATH];
686 TYPEATTR *attr;
687 LONG l;
689 hr = LoadTypeLib(wszStdOle2, &pTypeLib);
690 ok_ole_success(hr, LoadTypeLib);
692 count = ITypeLib_GetTypeInfoCount(pTypeLib);
693 ok(count > 0, "got %d\n", count);
695 /* invalid index */
696 hr = ITypeLib_GetTypeInfo(pTypeLib, count, &pTypeInfo);
697 ok(hr == TYPE_E_ELEMENTNOTFOUND, "got 0x%08x\n", hr);
699 hr = ITypeLib_GetTypeInfo(pTypeLib, 0, NULL);
700 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
702 hr = ITypeLib_GetLibAttr(pTypeLib, NULL);
703 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
705 hr = ITypeLib_GetTypeInfoType(pTypeLib, count, &kind);
706 ok(hr == TYPE_E_ELEMENTNOTFOUND, "got 0x%08x\n", hr);
708 hr = ITypeLib_GetTypeInfoType(pTypeLib, count, NULL);
709 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
711 hr = ITypeLib_GetTypeInfoType(pTypeLib, 0, NULL);
712 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
714 hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, &IID_IFont, &pTypeInfo);
715 ok_ole_success(hr, ITypeLib_GetTypeInfoOfGuid);
717 /* test nonexistent method name */
718 hr = ITypeInfo_GetIDsOfNames(pTypeInfo, &bogus, 1, &dispidMember);
719 ok(hr == DISP_E_UNKNOWNNAME,
720 "ITypeInfo_GetIDsOfNames should have returned DISP_E_UNKNOWNNAME instead of 0x%08x\n",
721 hr);
723 dispparams.cArgs = 0;
724 dispparams.rgdispidNamedArgs = NULL;
725 dispparams.rgvarg = NULL;
727 /* test dispparams not NULL */
729 /* invalid member id -- wrong flags -- cNamedArgs not bigger than cArgs */
730 dispparams.cNamedArgs = 0;
731 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, 0xdeadbeef, DISPATCH_PROPERTYGET, &dispparams, NULL, NULL, NULL);
732 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
733 /* invalid member id -- correct flags -- cNamedArgs not bigger than cArgs */
734 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, 0xdeadbeef, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
735 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
737 /* invalid member id -- wrong flags -- cNamedArgs bigger than cArgs */
738 dispparams.cNamedArgs = 1;
739 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, 0xdeadbeef, DISPATCH_PROPERTYGET, &dispparams, NULL, NULL, NULL);
740 ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr);
741 /* invalid member id -- correct flags -- cNamedArgs bigger than cArgs */
742 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, 0xdeadbeef, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
743 ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr);
746 hr = ITypeInfo_GetIDsOfNames(pTypeInfo, &pwszClone, 1, &dispidMember);
747 ok_ole_success(hr, ITypeInfo_GetIDsOfNames);
749 /* correct member id -- wrong flags -- cNamedArgs not bigger than cArgs */
750 dispparams.cNamedArgs = 0;
751 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, &dispparams, NULL, NULL, NULL);
752 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
753 /* correct member id -- correct flags -- cNamedArgs not bigger than cArgs */
754 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
755 ok(hr == DISP_E_BADPARAMCOUNT, "ITypeInfo_Invoke should have returned DISP_E_BADPARAMCOUNT instead of 0x%08x\n", hr);
757 /* correct member id -- wrong flags -- cNamedArgs bigger than cArgs */
758 dispparams.cNamedArgs = 1;
759 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, &dispparams, NULL, NULL, NULL);
760 ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr);
761 /* correct member id -- correct flags -- cNamedArgs bigger than cArgs */
762 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
763 ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr);
765 /* test NULL dispparams */
767 /* correct member id -- wrong flags -- cNamedArgs not bigger than cArgs */
768 dispparams.cNamedArgs = 0;
769 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, NULL, NULL, NULL, NULL);
770 ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr);
771 /* correct member id -- correct flags -- cNamedArgs not bigger than cArgs */
772 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, NULL, NULL, NULL, NULL);
773 ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr);
775 /* correct member id -- wrong flags -- cNamedArgs bigger than cArgs */
776 dispparams.cNamedArgs = 1;
777 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, NULL, NULL, NULL, NULL);
778 ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr);
779 /* correct member id -- correct flags -- cNamedArgs bigger than cArgs */
780 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, NULL, NULL, NULL, NULL);
781 ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr);
783 ITypeInfo_Release(pTypeInfo);
785 hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, &IID_IDispatch, &pTypeInfo);
786 ok_ole_success(hr, ITypeLib_GetTypeInfoOfGuid);
788 hr = ITypeInfo_GetIDsOfNames(pTypeInfo, &pwszGetTypeInfo, 1, &dispidMember);
789 ok_ole_success(hr, ITypeInfo_GetIDsOfNames);
791 hr = ITypeInfo_QueryInterface(pTypeInfo, &IID_ITypeInfo2, (void**)&pTypeInfo2);
792 ok_ole_success(hr, ITypeInfo_QueryInterface);
794 if (SUCCEEDED(hr))
796 VariantInit(&var);
798 V_VT(&var) = VT_I4;
800 /* test unknown guid passed to GetCustData */
801 hr = ITypeInfo2_GetCustData(pTypeInfo2, &bogusguid, &var);
802 ok_ole_success(hr, ITypeInfo_GetCustData);
803 ok(V_VT(&var) == VT_EMPTY, "got %i, expected VT_EMPTY\n", V_VT(&var));
805 ITypeInfo2_Release(pTypeInfo2);
807 VariantClear(&var);
810 /* Check instance size for IDispatch, typelib is loaded using system SYS_WIN* kind so it always matches
811 system bitness. */
812 hr = ITypeInfo_GetTypeAttr(pTypeInfo, &attr);
813 ok(hr == S_OK, "got 0x%08x\n", hr);
814 ok(attr->cbSizeInstance == sizeof(void*), "got size %d\n", attr->cbSizeInstance);
815 ok(attr->typekind == TKIND_INTERFACE, "got typekind %d\n", attr->typekind);
816 ITypeInfo_ReleaseTypeAttr(pTypeInfo, attr);
818 /* same size check with some general interface */
819 hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, &IID_IEnumVARIANT, &ti);
820 ok(hr == S_OK, "got 0x%08x\n", hr);
821 hr = ITypeInfo_GetTypeAttr(ti, &attr);
822 ok(hr == S_OK, "got 0x%08x\n", hr);
823 ok(attr->cbSizeInstance == sizeof(void*), "got size %d\n", attr->cbSizeInstance);
824 ITypeInfo_ReleaseTypeAttr(ti, attr);
825 ITypeInfo_Release(ti);
827 /* test invoking a method with a [restricted] keyword */
829 /* correct member id -- wrong flags -- cNamedArgs not bigger than cArgs */
830 dispparams.cNamedArgs = 0;
831 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, &dispparams, NULL, NULL, NULL);
832 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
833 /* correct member id -- correct flags -- cNamedArgs not bigger than cArgs */
834 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
835 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
837 /* correct member id -- wrong flags -- cNamedArgs bigger than cArgs */
838 dispparams.cNamedArgs = 1;
839 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, &dispparams, NULL, NULL, NULL);
840 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
841 /* correct member id -- correct flags -- cNamedArgs bigger than cArgs */
842 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
843 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
845 /* test NULL dispparams */
847 /* correct member id -- wrong flags -- cNamedArgs not bigger than cArgs */
848 dispparams.cNamedArgs = 0;
849 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, NULL, NULL, NULL, NULL);
850 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
851 /* correct member id -- correct flags -- cNamedArgs not bigger than cArgs */
852 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, NULL, NULL, NULL, NULL);
853 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
855 /* correct member id -- wrong flags -- cNamedArgs bigger than cArgs */
856 dispparams.cNamedArgs = 1;
857 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, NULL, NULL, NULL, NULL);
858 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
859 /* correct member id -- correct flags -- cNamedArgs bigger than cArgs */
860 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, NULL, NULL, NULL, NULL);
861 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
863 ITypeInfo_Release(pTypeInfo);
864 ITypeLib_Release(pTypeLib);
866 filenameA = create_test_typelib(3);
867 MultiByteToWideChar(CP_ACP, 0, filenameA, -1, filename, MAX_PATH);
868 hr = LoadTypeLib(filename, &pTypeLib);
869 ok(hr == S_OK, "got 0x%08x\n", hr);
871 hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, &IID_IInvokeTest, &pTypeInfo);
872 ok(hr == S_OK, "got 0x%08x\n", hr);
874 dispparams.cArgs = 1;
875 dispparams.cNamedArgs = 0;
876 dispparams.rgdispidNamedArgs = NULL;
877 dispparams.rgvarg = args;
879 V_VT(&args[0]) = VT_I4;
880 V_I4(&args[0]) = 0;
882 i = 0;
883 V_VT(&res) = VT_EMPTY;
884 V_I4(&res) = 0;
885 /* call propget with DISPATCH_METHOD|DISPATCH_PROPERTYGET flags */
886 hr = ITypeInfo_Invoke(pTypeInfo, &invoketest, DISPID_VALUE, DISPATCH_METHOD|DISPATCH_PROPERTYGET,
887 &dispparams, &res, NULL, &i);
888 ok(hr == S_OK, "got 0x%08x\n", hr);
889 ok(V_VT(&res) == VT_I4, "got %d\n", V_VT(&res));
890 ok(V_I4(&res) == 1, "got %d\n", V_I4(&res));
892 i = 0;
893 /* call propget with DISPATCH_METHOD flags */
894 hr = ITypeInfo_Invoke(pTypeInfo, &invoketest, DISPID_VALUE, DISPATCH_METHOD,
895 &dispparams, &res, NULL, &i);
896 ok(hr == DISP_E_MEMBERNOTFOUND, "got 0x%08x, %d\n", hr, i);
898 i = 0;
899 V_VT(&res) = VT_EMPTY;
900 V_I4(&res) = 0;
901 hr = ITypeInfo_Invoke(pTypeInfo, &invoketest, DISPID_VALUE, DISPATCH_PROPERTYGET,
902 &dispparams, &res, NULL, &i);
903 ok(hr == S_OK, "got 0x%08x, %d\n", hr, i);
904 ok(V_VT(&res) == VT_I4, "got %d\n", V_VT(&res));
905 ok(V_I4(&res) == 1, "got %d\n", V_I4(&res));
907 /* DISPATCH_PROPERTYPUTREF */
908 l = 1;
909 V_VT(&args[0]) = VT_I4|VT_BYREF;
910 V_I4REF(&args[0]) = &l;
912 dispidMember = DISPID_PROPERTYPUT;
913 dispparams.cArgs = 1;
914 dispparams.cNamedArgs = 1;
915 dispparams.rgdispidNamedArgs = &dispidMember;
916 dispparams.rgvarg = args;
918 i = 0;
919 V_VT(&res) = VT_EMPTY;
920 V_I4(&res) = 0;
921 hr = ITypeInfo_Invoke(pTypeInfo, &invoketest, 1, DISPATCH_PROPERTYPUTREF, &dispparams, &res, NULL, &i);
922 ok(hr == S_OK, "got 0x%08x, %d\n", hr, i);
923 ok(V_VT(&res) == VT_I4, "got %d\n", V_VT(&res));
924 ok(V_I4(&res) == 3, "got %d\n", V_I4(&res));
926 i = 0;
927 V_VT(&res) = VT_EMPTY;
928 V_I4(&res) = 0;
929 hr = ITypeInfo_Invoke(pTypeInfo, &invoketest, 1, DISPATCH_PROPERTYPUT, &dispparams, &res, NULL, &i);
930 ok(hr == DISP_E_MEMBERNOTFOUND, "got 0x%08x, %d\n", hr, i);
932 i = 0;
933 V_VT(&args[0]) = VT_UNKNOWN;
934 V_UNKNOWN(&args[0]) = NULL;
936 V_VT(&res) = VT_EMPTY;
937 V_I4(&res) = 0;
938 hr = ITypeInfo_Invoke(pTypeInfo, &invoketest, 2, DISPATCH_PROPERTYPUTREF, &dispparams, &res, NULL, &i);
939 ok(hr == S_OK, "got 0x%08x, %d\n", hr, i);
940 ok(V_VT(&res) == VT_I4, "got %d\n", V_VT(&res));
941 ok(V_I4(&res) == 6, "got %d\n", V_I4(&res));
943 i = 0;
944 V_VT(&res) = VT_EMPTY;
945 V_I4(&res) = 0;
946 hr = ITypeInfo_Invoke(pTypeInfo, &invoketest, 2, DISPATCH_PROPERTYPUT, &dispparams, &res, NULL, &i);
947 ok(hr == DISP_E_MEMBERNOTFOUND, "got 0x%08x, %d\n", hr, i);
949 ITypeInfo_Release(pTypeInfo);
950 ITypeLib_Release(pTypeLib);
951 DeleteFileA(filenameA);
954 static int WINAPI int_func( int a0, int a1, int a2, int a3, int a4 )
956 ok( a0 == 1, "wrong arg0 %x\n", a0 );
957 ok( a1 == -1, "wrong arg1 %x\n", a1 );
958 ok( a2 == (0x55550000 | 1234), "wrong arg2 %x\n", a2 );
959 ok( a3 == 0xdeadbeef, "wrong arg3 %x\n", a3 );
960 ok( a4 == 0x555555fd, "wrong arg4 %x\n", a4 );
961 return 4321;
964 static double WINAPI double_func( double a0, float a1, double a2, int a3 )
966 ok( a0 == 1.2, "wrong arg0 %f\n", (double)a0 );
967 ok( a1 == 3.25, "wrong arg1 %f\n", (double)a1 );
968 ok( a2 == 1.2e12, "wrong arg2 %f\n", (double)a2);
969 ok( a3 == -4433.0, "wrong arg3 %f\n", (double)a3 );
970 return 4321;
973 static LONGLONG WINAPI longlong_func( LONGLONG a0, CY a1 )
975 ok( a0 == (((ULONGLONG)0xdead << 32) | 0xbeef), "wrong arg0 %08x%08x\n", (DWORD)(a0 >> 32), (DWORD)a0);
976 ok( a1.int64 == ((ULONGLONG)10000 * 12345678), "wrong arg1 %08x%08x\n",
977 (DWORD)(a1.int64 >> 32), (DWORD)a1.int64 );
978 return ((ULONGLONG)4321 << 32) | 8765;
981 static VARIANT WINAPI variant_func( int a0, BOOL a1, DECIMAL a2, VARIANT a3 )
983 VARIANT var;
984 ok( a0 == 2233, "wrong arg0 %x\n", a0 );
985 ok( a1 == 1 || broken(a1 == 0x55550001), "wrong arg1 %x\n", a1 );
986 V_VT(&var) = VT_LPWSTR;
987 V_UI4(&var) = 0xbabe;
988 ok( a2.Hi32 == 1122, "wrong arg2.Hi32 %x\n", a2.Hi32 );
989 ok( U1(a2).Lo64 == 3344, "wrong arg2.Lo64 %08x%08x\n", (DWORD)(U1(a2).Lo64 >> 32), (DWORD)U1(a2).Lo64 );
990 ok( V_VT(&a3) == VT_EMPTY, "wrong arg3 type %x\n", V_VT(&a3) );
991 ok( V_UI4(&a3) == 0xdeadbeef, "wrong arg3 value %x\n", V_UI4(&a3) );
992 return var;
995 static int CDECL void_func( int a0, int a1 )
997 if (is_win64) /* VT_EMPTY is passed as real arg on win64 */
999 ok( a0 == 0x55555555, "wrong arg0 %x\n", a0 );
1000 ok( a1 == 1111, "wrong arg1 %x\n", a1 );
1002 else
1004 ok( a0 == 1111, "wrong arg0 %x\n", a0 );
1005 ok( a1 == 0, "wrong arg1 %x\n", a1 );
1007 return 12;
1010 static int WINAPI stdcall_func( int a )
1012 return 0;
1015 static int WINAPI inst_func( void *inst, int a )
1017 ok( (*(void ***)inst)[3] == inst_func, "wrong ptr %p\n", inst );
1018 ok( a == 3, "wrong arg %x\n", a );
1019 return a * 2;
1022 static HRESULT WINAPI ret_false_func(void)
1024 return S_FALSE;
1027 static const void *vtable[] = { NULL, NULL, NULL, inst_func };
1029 static void test_DispCallFunc(void)
1031 const void **inst = vtable;
1032 HRESULT res;
1033 VARIANT result, args[5];
1034 VARIANTARG *pargs[5];
1035 VARTYPE types[5];
1036 int i;
1038 for (i = 0; i < 5; i++) pargs[i] = &args[i];
1040 memset( args, 0x55, sizeof(args) );
1041 types[0] = VT_UI4;
1042 V_UI4(&args[0]) = 1;
1043 types[1] = VT_I4;
1044 V_I4(&args[1]) = -1;
1045 types[2] = VT_I2;
1046 V_I2(&args[2]) = 1234;
1047 types[3] = VT_UI4;
1048 V_UI4(&args[3]) = 0xdeadbeef;
1049 types[4] = VT_UI4;
1050 V_I1(&args[4]) = -3;
1051 memset( &result, 0xcc, sizeof(result) );
1052 res = DispCallFunc( NULL, (ULONG_PTR)int_func, CC_STDCALL, VT_UI4, 5, types, pargs, &result );
1053 ok( res == S_OK, "DispCallFunc failed %x\n", res );
1054 ok( V_VT(&result) == VT_UI4, "wrong result type %d\n", V_VT(&result) );
1055 ok( V_UI4(&result) == 4321, "wrong result %u\n", V_UI4(&result) );
1057 /* the function checks the argument sizes for stdcall */
1058 if (!is_win64) /* no stdcall on 64-bit */
1060 res = DispCallFunc( NULL, (ULONG_PTR)stdcall_func, CC_STDCALL, VT_UI4, 0, types, pargs, &result );
1061 ok( res == DISP_E_BADCALLEE, "DispCallFunc wrong error %x\n", res );
1062 res = DispCallFunc( NULL, (ULONG_PTR)stdcall_func, CC_STDCALL, VT_UI4, 1, types, pargs, &result );
1063 ok( res == S_OK, "DispCallFunc failed %x\n", res );
1064 res = DispCallFunc( NULL, (ULONG_PTR)stdcall_func, CC_STDCALL, VT_UI4, 2, types, pargs, &result );
1065 ok( res == DISP_E_BADCALLEE, "DispCallFunc wrong error %x\n", res );
1068 memset( args, 0x55, sizeof(args) );
1069 types[0] = VT_R8;
1070 V_R8(&args[0]) = 1.2;
1071 types[1] = VT_R4;
1072 V_R4(&args[1]) = 3.25;
1073 types[2] = VT_R8;
1074 V_R8(&args[2]) = 1.2e12;
1075 types[3] = VT_I4;
1076 V_I4(&args[3]) = -4433;
1077 memset( &result, 0xcc, sizeof(result) );
1078 res = DispCallFunc( NULL, (ULONG_PTR)double_func, CC_STDCALL, VT_R8, 4, types, pargs, &result );
1079 ok( res == S_OK, "DispCallFunc failed %x\n", res );
1080 ok( V_VT(&result) == VT_R8, "wrong result type %d\n", V_VT(&result) );
1081 ok( V_R8(&result) == 4321, "wrong result %f\n", V_R8(&result) );
1083 memset( args, 0x55, sizeof(args) );
1084 types[0] = VT_I8;
1085 V_I8(&args[0]) = ((ULONGLONG)0xdead << 32) | 0xbeef;
1086 types[1] = VT_CY;
1087 V_CY(&args[1]).int64 = (ULONGLONG)10000 * 12345678;
1088 memset( &result, 0xcc, sizeof(result) );
1089 res = DispCallFunc( NULL, (ULONG_PTR)longlong_func, CC_STDCALL, VT_I8, 2, types, pargs, &result );
1090 ok( res == S_OK || broken(res == E_INVALIDARG), /* longlong not supported on <= win2k */
1091 "DispCallFunc failed %x\n", res );
1092 if (res == S_OK)
1094 ok( V_VT(&result) == VT_I8, "wrong result type %d\n", V_VT(&result) );
1095 ok( V_I8(&result) == (((ULONGLONG)4321 << 32) | 8765), "wrong result %08x%08x\n",
1096 (DWORD)(V_I8(&result) >> 32), (DWORD)V_I8(&result) );
1099 memset( args, 0x55, sizeof(args) );
1100 types[0] = VT_I4;
1101 V_I4(&args[0]) = 2233;
1102 types[1] = VT_BOOL;
1103 V_BOOL(&args[1]) = 1;
1104 types[2] = VT_DECIMAL;
1105 V_DECIMAL(&args[2]).Hi32 = 1122;
1106 U1(V_DECIMAL(&args[2])).Lo64 = 3344;
1107 types[3] = VT_VARIANT;
1108 V_VT(&args[3]) = VT_EMPTY;
1109 V_UI4(&args[3]) = 0xdeadbeef;
1110 types[4] = VT_EMPTY;
1111 memset( &result, 0xcc, sizeof(result) );
1112 res = DispCallFunc( NULL, (ULONG_PTR)variant_func, CC_STDCALL, VT_VARIANT, 5, types, pargs, &result );
1113 ok( res == S_OK, "DispCallFunc failed %x\n", res );
1114 ok( V_VT(&result) == VT_LPWSTR, "wrong result type %d\n", V_VT(&result) );
1115 ok( V_UI4(&result) == 0xbabe, "wrong result %08x\n", V_UI4(&result) );
1117 memset( args, 0x55, sizeof(args) );
1118 types[0] = VT_EMPTY;
1119 types[1] = VT_I4;
1120 V_I4(&args[1]) = 1111;
1121 types[2] = VT_EMPTY;
1122 types[3] = VT_I4;
1123 V_I4(&args[3]) = 0;
1124 types[4] = VT_EMPTY;
1125 memset( &result, 0xcc, sizeof(result) );
1126 res = DispCallFunc( NULL, (ULONG_PTR)void_func, CC_CDECL, VT_EMPTY, 5, types, pargs, &result );
1127 ok( res == S_OK, "DispCallFunc failed %x\n", res );
1128 ok( V_VT(&result) == VT_EMPTY, "wrong result type %d\n", V_VT(&result) );
1129 if (is_win64)
1130 ok( V_UI4(&result) == 12, "wrong result %08x\n", V_UI4(&result) );
1131 else
1132 ok( V_UI4(&result) == 0xcccccccc, "wrong result %08x\n", V_UI4(&result) );
1134 memset( args, 0x55, sizeof(args) );
1135 types[0] = VT_I4;
1136 V_I4(&args[0]) = 3;
1137 memset( &result, 0xcc, sizeof(result) );
1138 res = DispCallFunc( &inst, 3 * sizeof(void*), CC_STDCALL, VT_I4, 1, types, pargs, &result );
1139 ok( res == S_OK, "DispCallFunc failed %x\n", res );
1140 ok( V_VT(&result) == VT_I4, "wrong result type %d\n", V_VT(&result) );
1141 ok( V_I4(&result) == 6, "wrong result %08x\n", V_I4(&result) );
1143 memset( &result, 0xcc, sizeof(result) );
1144 res = DispCallFunc(NULL, (ULONG_PTR)ret_false_func, CC_STDCALL, VT_ERROR, 0, NULL, NULL, &result);
1145 ok(res == S_OK, "DispCallFunc failed: %08x\n", res);
1146 ok(V_VT(&result) == VT_ERROR, "V_VT(result) = %u\n", V_VT(&result));
1147 ok(V_ERROR(&result) == S_FALSE, "V_ERROR(result) = %08x\n", V_ERROR(&result));
1149 memset( &result, 0xcc, sizeof(result) );
1150 res = DispCallFunc(NULL, (ULONG_PTR)ret_false_func, CC_STDCALL, VT_HRESULT, 0, NULL, NULL, &result);
1151 ok(res == E_INVALIDARG, "DispCallFunc failed: %08x\n", res);
1152 ok(V_VT(&result) == 0xcccc, "V_VT(result) = %u\n", V_VT(&result));
1155 /* RegDeleteTreeW from dlls/advapi32/registry.c */
1156 static LSTATUS myRegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey)
1158 LONG ret;
1159 DWORD dwMaxSubkeyLen, dwMaxValueLen;
1160 DWORD dwMaxLen, dwSize;
1161 WCHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
1162 HKEY hSubKey = hKey;
1164 if(lpszSubKey)
1166 ret = RegOpenKeyExW(hKey, lpszSubKey, 0, KEY_READ, &hSubKey);
1167 if (ret) return ret;
1170 ret = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL,
1171 &dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL);
1172 if (ret) goto cleanup;
1174 dwMaxSubkeyLen++;
1175 dwMaxValueLen++;
1176 dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
1177 if (dwMaxLen > sizeof(szNameBuf)/sizeof(WCHAR))
1179 /* Name too big: alloc a buffer for it */
1180 if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR))))
1182 ret = ERROR_NOT_ENOUGH_MEMORY;
1183 goto cleanup;
1187 /* Recursively delete all the subkeys */
1188 while (TRUE)
1190 dwSize = dwMaxLen;
1191 if (RegEnumKeyExW(hSubKey, 0, lpszName, &dwSize, NULL,
1192 NULL, NULL, NULL)) break;
1194 ret = myRegDeleteTreeW(hSubKey, lpszName);
1195 if (ret) goto cleanup;
1198 if (lpszSubKey)
1199 ret = RegDeleteKeyW(hKey, lpszSubKey);
1200 else
1201 while (TRUE)
1203 dwSize = dwMaxLen;
1204 if (RegEnumValueW(hKey, 0, lpszName, &dwSize,
1205 NULL, NULL, NULL, NULL)) break;
1207 ret = RegDeleteValueW(hKey, lpszName);
1208 if (ret) goto cleanup;
1211 cleanup:
1212 if (lpszName != szNameBuf)
1213 HeapFree(GetProcessHeap(), 0, lpszName);
1214 if(lpszSubKey)
1215 RegCloseKey(hSubKey);
1216 return ret;
1219 static BOOL do_typelib_reg_key(GUID *uid, WORD maj, WORD min, DWORD arch, LPCWSTR base, BOOL remove)
1221 static const WCHAR typelibW[] = {'T','y','p','e','l','i','b','\\',0};
1222 static const WCHAR formatW[] = {'\\','%','u','.','%','u','\\','0','\\','w','i','n','%','u',0};
1223 static const WCHAR format2W[] = {'%','s','_','%','u','_','%','u','.','d','l','l',0};
1224 WCHAR buf[128];
1225 HKEY hkey;
1226 BOOL ret = TRUE;
1227 DWORD res;
1229 memcpy(buf, typelibW, sizeof(typelibW));
1230 StringFromGUID2(uid, buf + lstrlenW(buf), 40);
1232 if (remove)
1234 ok(myRegDeleteTreeW(HKEY_CLASSES_ROOT, buf) == ERROR_SUCCESS, "SHDeleteKey failed\n");
1235 return TRUE;
1238 wsprintfW(buf + lstrlenW(buf), formatW, maj, min, arch);
1240 SetLastError(0xdeadbeef);
1241 res = RegCreateKeyExW(HKEY_CLASSES_ROOT, buf, 0, NULL, 0,
1242 KEY_WRITE, NULL, &hkey, NULL);
1243 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
1245 win_skip("W-calls are not implemented\n");
1246 return FALSE;
1249 if (res != ERROR_SUCCESS)
1251 trace("RegCreateKeyExW failed: %u\n", res);
1252 return FALSE;
1255 wsprintfW(buf, format2W, base, maj, min);
1256 if (RegSetValueExW(hkey, NULL, 0, REG_SZ,
1257 (BYTE *)buf, (lstrlenW(buf) + 1) * sizeof(WCHAR)) != ERROR_SUCCESS)
1259 trace("RegSetValueExW failed\n");
1260 ret = FALSE;
1262 RegCloseKey(hkey);
1263 return ret;
1266 static void test_QueryPathOfRegTypeLib(DWORD arch)
1268 static const struct test_data
1270 WORD maj, min;
1271 HRESULT ret;
1272 const WCHAR path[16];
1273 } td[] = {
1274 { 1, 0, TYPE_E_LIBNOTREGISTERED, { 0 } },
1275 { 3, 0, S_OK, {'f','a','k','e','_','3','_','0','.','d','l','l',0 } },
1276 { 3, 1, S_OK, {'f','a','k','e','_','3','_','1','.','d','l','l',0 } },
1277 { 3, 22, S_OK, {'f','a','k','e','_','3','_','3','7','.','d','l','l',0 } },
1278 { 3, 37, S_OK, {'f','a','k','e','_','3','_','3','7','.','d','l','l',0 } },
1279 { 3, 40, S_OK, {'f','a','k','e','_','3','_','3','7','.','d','l','l',0 } },
1280 { 0xffff, 0xffff, S_OK, {'f','a','k','e','_','5','_','3','7','.','d','l','l',0 } },
1281 { 0xffff, 0, TYPE_E_LIBNOTREGISTERED, { 0 } },
1282 { 3, 0xffff, TYPE_E_LIBNOTREGISTERED, { 0 } },
1283 { 5, 0xffff, TYPE_E_LIBNOTREGISTERED, { 0 } },
1284 { 4, 0, TYPE_E_LIBNOTREGISTERED, { 0 } }
1286 static const WCHAR base[] = {'f','a','k','e',0};
1287 static const WCHAR wrongW[] = {'w','r','o','n','g',0};
1288 UINT i;
1289 RPC_STATUS status;
1290 GUID uid;
1291 WCHAR uid_str[40];
1292 HRESULT ret;
1293 BSTR path;
1295 status = UuidCreate(&uid);
1296 ok(!status || status == RPC_S_UUID_LOCAL_ONLY, "UuidCreate error %08x\n", status);
1298 StringFromGUID2(&uid, uid_str, 40);
1299 /*trace("GUID: %s\n", wine_dbgstr_w(uid_str));*/
1301 if (!do_typelib_reg_key(&uid, 3, 0, arch, base, 0)) return;
1302 if (!do_typelib_reg_key(&uid, 3, 1, arch, base, 0)) return;
1303 if (!do_typelib_reg_key(&uid, 3, 37, arch, base, 0)) return;
1304 if (!do_typelib_reg_key(&uid, 5, 37, arch, base, 0)) return;
1305 if (arch == 64 && !do_typelib_reg_key(&uid, 5, 37, 32, wrongW, 0)) return;
1307 for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
1309 ret = QueryPathOfRegTypeLib(&uid, td[i].maj, td[i].min, LOCALE_NEUTRAL, &path);
1310 ok(ret == td[i].ret, "QueryPathOfRegTypeLib(%u.%u) returned %08x\n", td[i].maj, td[i].min, ret);
1311 if (ret == S_OK)
1313 ok(!lstrcmpW(td[i].path, path), "typelib %u.%u path doesn't match\n", td[i].maj, td[i].min);
1314 SysFreeString(path);
1318 do_typelib_reg_key(&uid, 0, 0, arch, NULL, 1);
1321 static void test_inheritance(void)
1323 HRESULT hr;
1324 ITypeLib *pTL;
1325 ITypeInfo *pTI, *pTI_p;
1326 TYPEATTR *pTA;
1327 HREFTYPE href;
1328 FUNCDESC *pFD;
1329 WCHAR path[MAX_PATH];
1330 CHAR pathA[MAX_PATH];
1331 static const WCHAR tl_path[] = {'.','\\','m','i','d','l','_','t','m','a','r','s','h','a','l','.','t','l','b',0};
1333 BOOL use_midl_tlb = FALSE;
1335 GetModuleFileNameA(NULL, pathA, MAX_PATH);
1336 MultiByteToWideChar(CP_ACP, 0, pathA, -1, path, MAX_PATH);
1338 if(use_midl_tlb)
1339 memcpy(path, tl_path, sizeof(tl_path));
1341 hr = LoadTypeLib(path, &pTL);
1342 if(FAILED(hr)) return;
1345 /* ItestIF3 is a syntax 2 dispinterface */
1346 hr = ITypeLib_GetTypeInfoOfGuid(pTL, &DIID_ItestIF3, &pTI);
1347 ok(hr == S_OK, "hr %08x\n", hr);
1349 hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1350 ok(hr == S_OK, "hr %08x\n", hr);
1351 ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
1352 ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1353 ok(pTA->wTypeFlags == TYPEFLAG_FDISPATCHABLE, "typeflags %x\n", pTA->wTypeFlags);
1354 if(use_midl_tlb) {
1355 ok(pTA->cFuncs == 6, "cfuncs %d\n", pTA->cFuncs);
1356 ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1358 ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1360 if(use_midl_tlb) {
1361 hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
1362 ok(hr == S_OK, "hr %08x\n", hr);
1363 hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1364 ok(hr == S_OK, "hr %08x\n", hr);
1365 hr = ITypeInfo_GetTypeAttr(pTI_p, &pTA);
1366 ok(hr == S_OK, "got %08x\n", hr);
1367 ok(IsEqualGUID(&pTA->guid, &IID_IDispatch), "guid {%08x-....\n", pTA->guid.Data1);
1368 ITypeInfo_ReleaseTypeAttr(pTI_p, pTA);
1369 ITypeInfo_Release(pTI_p);
1371 /* Should have six methods */
1372 hr = ITypeInfo_GetFuncDesc(pTI, 6, &pFD);
1373 ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
1374 hr = ITypeInfo_GetFuncDesc(pTI, 5, &pFD);
1375 ok(hr == S_OK, "hr %08x\n", hr);
1376 ok(pFD->memid == 0x60020000, "memid %08x\n", pFD->memid);
1377 ok(pFD->oVft == 5 * sizeof(void *), "oVft %d\n", pFD->oVft);
1378 ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1380 ITypeInfo_Release(pTI);
1383 /* ItestIF4 is a syntax 1 dispinterface */
1384 hr = ITypeLib_GetTypeInfoOfGuid(pTL, &DIID_ItestIF4, &pTI);
1385 ok(hr == S_OK, "hr %08x\n", hr);
1387 hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1388 ok(hr == S_OK, "hr %08x\n", hr);
1389 ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
1390 ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1391 ok(pTA->wTypeFlags == TYPEFLAG_FDISPATCHABLE, "typeflags %x\n", pTA->wTypeFlags);
1392 ok(pTA->cFuncs == 1, "cfuncs %d\n", pTA->cFuncs);
1393 ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1394 ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1396 hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
1397 ok(hr == S_OK, "hr %08x\n", hr);
1398 hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1399 ok(hr == S_OK, "hr %08x\n", hr);
1400 hr = ITypeInfo_GetTypeAttr(pTI_p, &pTA);
1401 ok(hr == S_OK, "got %08x\n", hr);
1402 ok(IsEqualGUID(&pTA->guid, &IID_IDispatch), "guid {%08x-....\n", pTA->guid.Data1);
1403 ITypeInfo_ReleaseTypeAttr(pTI_p, pTA);
1404 ITypeInfo_Release(pTI_p);
1405 hr = ITypeInfo_GetFuncDesc(pTI, 1, &pFD);
1406 ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
1407 hr = ITypeInfo_GetFuncDesc(pTI, 0, &pFD);
1408 ok(hr == S_OK, "hr %08x\n", hr);
1409 ok(pFD->memid == 0x1c, "memid %08x\n", pFD->memid);
1410 ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1411 ITypeInfo_Release(pTI);
1414 /* ItestIF5 is dual with inherited ifaces which derive from IUnknown but not IDispatch */
1415 hr = ITypeLib_GetTypeInfoOfGuid(pTL, &IID_ItestIF5, &pTI);
1416 ok(hr == S_OK, "hr %08x\n", hr);
1418 hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1419 ok(hr == S_OK, "hr %08x\n", hr);
1420 if (hr == S_OK)
1422 ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
1423 ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1424 if(use_midl_tlb) {
1425 ok(pTA->wTypeFlags == TYPEFLAG_FDUAL, "typeflags %x\n", pTA->wTypeFlags);
1427 ok(pTA->cFuncs == 8, "cfuncs %d\n", pTA->cFuncs);
1428 ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1429 ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1431 hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
1432 ok(hr == S_OK, "hr %08x\n", hr);
1433 hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1434 ok(hr == S_OK, "hr %08x\n", hr);
1435 hr = ITypeInfo_GetTypeAttr(pTI_p, &pTA);
1436 ok(hr == S_OK, "got %08x\n", hr);
1437 ok(IsEqualGUID(&pTA->guid, &IID_IDispatch), "guid {%08x-....\n", pTA->guid.Data1);
1438 ITypeInfo_ReleaseTypeAttr(pTI_p, pTA);
1439 ITypeInfo_Release(pTI_p);
1440 if(use_midl_tlb) {
1441 hr = ITypeInfo_GetFuncDesc(pTI, 6, &pFD);
1442 ok(hr == S_OK, "hr %08x\n", hr);
1443 ok(pFD->memid == 0x1234, "memid %08x\n", pFD->memid);
1444 ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1446 ITypeInfo_Release(pTI);
1448 /* ItestIF7 is dual with inherited ifaces which derive from Dispatch */
1449 hr = ITypeLib_GetTypeInfoOfGuid(pTL, &IID_ItestIF7, &pTI);
1450 ok(hr == S_OK, "hr %08x\n", hr);
1452 hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1453 ok(hr == S_OK, "hr %08x\n", hr);
1454 ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
1455 ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1456 ok(pTA->wTypeFlags == (TYPEFLAG_FDISPATCHABLE|TYPEFLAG_FDUAL), "typeflags %x\n", pTA->wTypeFlags);
1457 ok(pTA->cFuncs == 10, "cfuncs %d\n", pTA->cFuncs);
1458 ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1459 ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1461 hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
1462 ok(hr == S_OK, "hr %08x\n", hr);
1463 hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1464 ok(hr == S_OK, "hr %08x\n", hr);
1465 hr = ITypeInfo_GetTypeAttr(pTI_p, &pTA);
1466 ok(hr == S_OK, "got %08x\n", hr);
1467 ok(IsEqualGUID(&pTA->guid, &IID_IDispatch), "guid {%08x-....\n", pTA->guid.Data1);
1468 ITypeInfo_ReleaseTypeAttr(pTI_p, pTA);
1469 ITypeInfo_Release(pTI_p);
1471 hr = ITypeInfo_GetFuncDesc(pTI, 9, &pFD);
1472 ok(hr == S_OK, "hr %08x\n", hr);
1473 ok(pFD->memid == 0x1236, "memid %08x\n", pFD->memid);
1474 ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1475 ITypeInfo_Release(pTI);
1477 /* ItestIF10 is a syntax 2 dispinterface which doesn't derive from IUnknown */
1478 hr = ITypeLib_GetTypeInfoOfGuid(pTL, &DIID_ItestIF10, &pTI);
1479 ok(hr == S_OK, "hr %08x\n", hr);
1481 hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1482 ok(hr == S_OK, "hr %08x\n", hr);
1483 ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
1484 ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1485 ok(pTA->wTypeFlags == TYPEFLAG_FDISPATCHABLE, "typeflags %x\n", pTA->wTypeFlags);
1486 if(use_midl_tlb) {
1487 ok(pTA->cFuncs == 3, "cfuncs %d\n", pTA->cFuncs);
1488 ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1490 ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1492 if(use_midl_tlb) {
1493 hr = ITypeInfo_GetRefTypeOfImplType(pTI, -1, &href);
1494 ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
1495 hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
1496 ok(hr == S_OK, "hr %08x\n", hr);
1497 hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1498 ok(hr == S_OK, "hr %08x\n", hr);
1499 hr = ITypeInfo_GetTypeAttr(pTI_p, &pTA);
1500 ok(hr == S_OK, "got %08x\n", hr);
1501 ok(IsEqualGUID(&pTA->guid, &IID_IDispatch), "guid {%08x-....\n", pTA->guid.Data1);
1502 ITypeInfo_ReleaseTypeAttr(pTI_p, pTA);
1503 ITypeInfo_Release(pTI_p);
1505 /* Should have three methods */
1506 hr = ITypeInfo_GetFuncDesc(pTI, 3, &pFD);
1507 ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
1508 hr = ITypeInfo_GetFuncDesc(pTI, 2, &pFD);
1509 ok(hr == S_OK, "hr %08x\n", hr);
1510 ok(pFD->memid == 0x60010000, "memid %08x\n", pFD->memid);
1511 ok(pFD->oVft == 2 * sizeof(void *), "oVft %d\n", pFD->oVft);
1512 ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1514 ITypeInfo_Release(pTI);
1516 /* ItestIF11 is a syntax 2 dispinterface which derives from IDispatch */
1517 hr = ITypeLib_GetTypeInfoOfGuid(pTL, &DIID_ItestIF11, &pTI);
1518 ok(hr == S_OK, "hr %08x\n", hr);
1520 hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1521 ok(hr == S_OK, "hr %08x\n", hr);
1522 ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
1523 ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1524 ok(pTA->wTypeFlags == TYPEFLAG_FDISPATCHABLE, "typeflags %x\n", pTA->wTypeFlags);
1525 if(use_midl_tlb) {
1526 ok(pTA->cFuncs == 10, "cfuncs %d\n", pTA->cFuncs);
1527 ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1529 ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1531 if(use_midl_tlb) {
1532 hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
1533 ok(hr == S_OK, "hr %08x\n", hr);
1534 hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1535 ok(hr == S_OK, "hr %08x\n", hr);
1536 hr = ITypeInfo_GetTypeAttr(pTI_p, &pTA);
1537 ok(hr == S_OK, "got %08x\n", hr);
1538 ok(IsEqualGUID(&pTA->guid, &IID_IDispatch), "guid {%08x-....\n", pTA->guid.Data1);
1539 ITypeInfo_ReleaseTypeAttr(pTI_p, pTA);
1540 ITypeInfo_Release(pTI_p);
1542 /* Should have ten methods */
1543 hr = ITypeInfo_GetFuncDesc(pTI, 10, &pFD);
1544 ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
1545 hr = ITypeInfo_GetFuncDesc(pTI, 9, &pFD);
1546 ok(hr == S_OK, "hr %08x\n", hr);
1547 ok(pFD->memid == 0x1236, "memid %08x\n", pFD->memid);
1548 ok(pFD->oVft == 9 * sizeof(void *), "oVft %d\n", pFD->oVft);
1550 /* first argument to 10th function is an HREFTYPE from the impl type */
1551 ok(pFD->cParams == 1, "cParams %i\n", pFD->cParams);
1552 ok(pFD->lprgelemdescParam[0].tdesc.vt == VT_USERDEFINED,
1553 "vt 0x%x\n", pFD->lprgelemdescParam[0].tdesc.vt);
1554 href = U(pFD->lprgelemdescParam[0].tdesc).hreftype;
1555 ok((href & 0xff000000) == 0x04000000, "href 0x%08x\n", href);
1556 hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1557 ok(hr == S_OK, "hr %08x\n", hr);
1558 if (SUCCEEDED(hr)) ITypeInfo_Release(pTI_p);
1559 ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1561 ITypeInfo_Release(pTI);
1564 /* ItestIF2 is an interface which derives from IUnknown */
1565 hr = ITypeLib_GetTypeInfoOfGuid(pTL, &IID_ItestIF2, &pTI);
1566 ok(hr == S_OK, "hr %08x\n", hr);
1568 hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1569 ok(hr == S_OK, "hr %08x\n", hr);
1570 ok(pTA->typekind == TKIND_INTERFACE, "kind %04x\n", pTA->typekind);
1571 ok(pTA->cbSizeVft == 6 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1572 ok(pTA->wTypeFlags == 0, "typeflags %x\n", pTA->wTypeFlags);
1573 if(use_midl_tlb) {
1574 ok(pTA->cFuncs == 1, "cfuncs %d\n", pTA->cFuncs);
1575 ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1577 ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1579 if(use_midl_tlb) {
1580 /* Should have one method */
1581 hr = ITypeInfo_GetFuncDesc(pTI, 1, &pFD);
1582 ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
1583 hr = ITypeInfo_GetFuncDesc(pTI, 0, &pFD);
1584 ok(hr == S_OK, "hr %08x\n", hr);
1585 ok(pFD->memid == 0x60020000, "memid %08x\n", pFD->memid);
1586 ok(pFD->oVft == 5 * sizeof(void *), "oVft %d\n", pFD->oVft);
1587 ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1589 ITypeInfo_Release(pTI);
1591 ITypeLib_Release(pTL);
1593 return;
1596 static void test_CreateTypeLib(SYSKIND sys) {
1597 static OLECHAR typelibW[] = {'t','y','p','e','l','i','b',0};
1598 static OLECHAR helpfileW[] = {'C',':','\\','b','o','g','u','s','.','h','l','p',0};
1599 static OLECHAR interface1W[] = {'i','n','t','e','r','f','a','c','e','1',0};
1600 static OLECHAR interface2W[] = {'i','n','t','e','r','f','a','c','e','2',0};
1601 static OLECHAR interface3W[] = {'i','n','t','e','r','f','a','c','e','3',0};
1602 static OLECHAR dualW[] = {'d','u','a','l',0};
1603 static OLECHAR coclassW[] = {'c','o','c','l','a','s','s',0};
1604 static const WCHAR defaultW[] = {'d','e','f','a','u','l','t',0x3213,0};
1605 static const WCHAR defaultQW[] = {'d','e','f','a','u','l','t','?',0};
1606 static OLECHAR func1W[] = {'f','u','n','c','1',0};
1607 static OLECHAR func2W[] = {'f','u','n','c','2',0};
1608 static OLECHAR prop1W[] = {'P','r','o','p','1',0};
1609 static OLECHAR param1W[] = {'p','a','r','a','m','1',0};
1610 static OLECHAR param2W[] = {'p','a','r','a','m','2',0};
1611 static OLECHAR asdfW[] = {'A','s','d','f',0};
1612 static OLECHAR aliasW[] = {'a','l','i','a','s',0};
1613 static OLECHAR invokeW[] = {'I','n','v','o','k','e',0};
1614 static OLECHAR *names1[] = {func1W, param1W, param2W};
1615 static OLECHAR *names2[] = {func2W, param1W, param2W};
1616 static OLECHAR *propname[] = {prop1W, param1W};
1617 static const GUID custguid = {0xbf611abe,0x5b38,0x11df,{0x91,0x5c,0x08,0x02,0x79,0x79,0x94,0x70}};
1618 static const GUID bogusguid = {0xbf611abe,0x5b38,0x11df,{0x91,0x5c,0x08,0x02,0x79,0x79,0x94,0x71}};
1619 static const GUID interfaceguid = {0x3b9ff02f,0x9675,0x4861,{0xb7,0x81,0xce,0xae,0xa4,0x78,0x2a,0xcc}};
1620 static const GUID interface2guid = {0x3b9ff02f,0x9675,0x4861,{0xb7,0x81,0xce,0xae,0xa4,0x78,0x2a,0xcd}};
1622 char filename[MAX_PATH];
1623 WCHAR filenameW[MAX_PATH];
1624 ICreateTypeLib2 *createtl;
1625 ICreateTypeInfo *createti;
1626 ICreateTypeInfo2 *createti2;
1627 ITypeLib *tl, *stdole;
1628 ITypeInfo *interface1, *interface2, *dual, *unknown, *dispatch, *ti;
1629 ITypeInfo *tinfos[2];
1630 ITypeInfo2 *ti2;
1631 ITypeComp *tcomp;
1632 MEMBERID memids[2];
1633 FUNCDESC funcdesc, *pfuncdesc;
1634 ELEMDESC elemdesc[5], *edesc;
1635 PARAMDESCEX paramdescex;
1636 TYPEDESC typedesc1, typedesc2;
1637 TYPEATTR *typeattr;
1638 TLIBATTR *libattr;
1639 HREFTYPE hreftype;
1640 BSTR name, docstring, helpfile, names[3];
1641 DWORD helpcontext, ptr_size, alignment;
1642 int impltypeflags;
1643 unsigned int cnames;
1644 USHORT found;
1645 VARIANT cust_data;
1646 HRESULT hres;
1647 TYPEKIND kind;
1648 DESCKIND desckind;
1649 BINDPTR bindptr;
1651 switch(sys){
1652 case SYS_WIN32:
1653 trace("testing SYS_WIN32\n");
1654 ptr_size = 4;
1655 alignment = sizeof(void*);
1656 break;
1657 case SYS_WIN64:
1658 trace("testing SYS_WIN64\n");
1659 ptr_size = 8;
1660 alignment = 4;
1661 break;
1662 default:
1663 return;
1666 trace("CreateTypeLib tests\n");
1668 hres = LoadTypeLib(wszStdOle2, &stdole);
1669 ok(hres == S_OK, "got %08x\n", hres);
1671 hres = ITypeLib_GetTypeInfoOfGuid(stdole, &IID_IUnknown, &unknown);
1672 ok(hres == S_OK, "got %08x\n", hres);
1674 hres = ITypeInfo_GetTypeAttr(unknown, &typeattr);
1675 ok(hres == S_OK, "got %08x\n", hres);
1676 ok(typeattr->cbSizeVft == 3 * sizeof(void*), "Got wrong cbSizeVft: %u\n", typeattr->cbSizeVft);
1677 ITypeInfo_ReleaseTypeAttr(unknown, typeattr);
1679 hres = ITypeLib_GetTypeInfoOfGuid(stdole, &IID_IDispatch, &dispatch);
1680 ok(hres == S_OK, "got %08x\n", hres);
1682 GetTempFileNameA(".", "tlb", 0, filename);
1683 MultiByteToWideChar(CP_ACP, 0, filename, -1, filenameW, MAX_PATH);
1685 hres = CreateTypeLib2(sys, filenameW, &createtl);
1686 ok(hres == S_OK, "got %08x\n", hres);
1688 hres = ICreateTypeLib2_QueryInterface(createtl, &IID_ITypeLib, (void**)&tl);
1689 ok(hres == S_OK, "got %08x\n", hres);
1691 hres = ITypeLib_GetTypeInfo(tl, 0, NULL);
1692 ok(hres == E_INVALIDARG, "got 0x%08x\n", hres);
1694 hres = ITypeLib_GetTypeInfoType(tl, 0, &kind);
1695 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got 0x%08x\n", hres);
1697 hres = ITypeLib_GetTypeInfoType(tl, 0, NULL);
1698 ok(hres == E_INVALIDARG, "got 0x%08x\n", hres);
1700 hres = ITypeLib_GetTypeInfoType(tl, 0, NULL);
1701 ok(hres == E_INVALIDARG, "got 0x%08x\n", hres);
1703 hres = ITypeLib_GetLibAttr(tl, NULL);
1704 ok(hres == E_INVALIDARG, "got %08x\n", hres);
1706 hres = ITypeLib_GetLibAttr(tl, &libattr);
1707 ok(hres == S_OK, "got %08x\n", hres);
1709 ok(libattr->syskind == sys, "syskind = %d\n", libattr->syskind);
1710 ok(libattr->wMajorVerNum == 0, "wMajorVer = %d\n", libattr->wMajorVerNum);
1711 ok(libattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", libattr->wMinorVerNum);
1712 ok(libattr->wLibFlags == 0, "wLibFlags = %d\n", libattr->wLibFlags);
1714 ITypeLib_ReleaseTLibAttr(tl, libattr);
1716 name = (BSTR)0xdeadbeef;
1717 hres = ITypeLib_GetDocumentation(tl, -1, &name, &docstring, &helpcontext, &helpfile);
1718 ok(hres == S_OK, "got %08x\n", hres);
1719 ok(name == NULL, "name != NULL\n");
1720 ok(docstring == NULL, "docstring != NULL\n");
1721 ok(helpcontext == 0, "helpcontext != 0\n");
1722 ok(helpfile == NULL, "helpfile != NULL\n");
1724 hres = ITypeLib_GetDocumentation(tl, 0, &name, NULL, NULL, NULL);
1725 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
1727 hres = ICreateTypeLib2_SetName(createtl, typelibW);
1728 ok(hres == S_OK, "got %08x\n", hres);
1730 hres = ICreateTypeLib2_SetHelpFileName(createtl, helpfileW);
1731 ok(hres == S_OK, "got %08x\n", hres);
1733 hres = ITypeLib_GetDocumentation(tl, -1, NULL, NULL, NULL, NULL);
1734 ok(hres == S_OK, "got %08x\n", hres);
1736 hres = ITypeLib_GetDocumentation(tl, -1, &name, NULL, NULL, &helpfile);
1737 ok(hres == S_OK, "got %08x\n", hres);
1738 ok(!memcmp(name, typelibW, sizeof(typelibW)), "name = %s\n", wine_dbgstr_w(name));
1739 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "helpfile = %s\n", wine_dbgstr_w(helpfile));
1741 SysFreeString(name);
1742 SysFreeString(helpfile);
1744 /* invalid parameters */
1745 hres = ICreateTypeLib2_CreateTypeInfo(createtl, NULL, TKIND_INTERFACE, &createti);
1746 ok(hres == E_INVALIDARG, "got %08x\n", hres);
1748 hres = ICreateTypeLib2_CreateTypeInfo(createtl, interface1W, TKIND_INTERFACE, NULL);
1749 ok(hres == E_INVALIDARG, "got %08x\n", hres);
1751 hres = ICreateTypeLib2_CreateTypeInfo(createtl, NULL, TKIND_INTERFACE, NULL);
1752 ok(hres == E_INVALIDARG, "got %08x\n", hres);
1754 hres = ICreateTypeLib2_CreateTypeInfo(createtl, interface1W, TKIND_INTERFACE, &createti);
1755 ok(hres == S_OK, "got %08x\n", hres);
1757 hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&interface1);
1758 ok(hres == S_OK, "got %08x\n", hres);
1760 hres = ITypeLib_GetDocumentation(tl, 0, &name, NULL, NULL, NULL);
1761 ok(hres == S_OK, "got %08x\n", hres);
1762 ok(!memcmp(name, interface1W, sizeof(interface1W)), "name = %s\n", wine_dbgstr_w(name));
1764 SysFreeString(name);
1766 ITypeLib_Release(tl);
1768 name = (BSTR)0xdeadbeef;
1769 helpfile = (BSTR)0xdeadbeef;
1770 hres = ITypeInfo_GetDocumentation(interface1, -1, &name, &docstring, &helpcontext, &helpfile);
1771 ok(hres == S_OK, "got %08x\n", hres);
1772 ok(!memcmp(name, interface1W, sizeof(interface1W)), "name = %s\n", wine_dbgstr_w(name));
1773 ok(docstring == NULL, "docstring != NULL\n");
1774 ok(helpcontext == 0, "helpcontext != 0\n");
1775 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "helpfile = %s\n", wine_dbgstr_w(helpfile));
1777 SysFreeString(name);
1778 SysFreeString(helpfile);
1780 hres = ITypeInfo_GetDocumentation(interface1, 0, &name, NULL, NULL, NULL);
1781 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
1783 hres = ITypeInfo_GetRefTypeInfo(interface1, 0, NULL);
1784 ok(hres == E_INVALIDARG, "got %08x\n", hres);
1787 hres = ICreateTypeInfo_LayOut(createti);
1788 ok(hres == S_OK, "got %08x\n", hres);
1790 hres = ICreateTypeInfo_SetGuid(createti, &interfaceguid);
1791 ok(hres == S_OK, "got %08x\n", hres);
1793 hres = ICreateTypeInfo_AddRefTypeInfo(createti, NULL, &hreftype);
1794 ok(hres == E_INVALIDARG, "got %08x\n", hres);
1796 hres = ICreateTypeInfo_AddRefTypeInfo(createti, unknown, NULL);
1797 ok(hres == E_INVALIDARG, "got %08x\n", hres);
1799 hres = ICreateTypeInfo_AddRefTypeInfo(createti, unknown, &hreftype);
1800 ok(hres == S_OK, "got %08x\n", hres);
1801 if(hres != S_OK) {
1802 skip("Skipping some tests\n");
1803 return;
1806 hres = ICreateTypeInfo_AddImplType(createti, 1, hreftype);
1807 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
1809 hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype);
1810 ok(hres == S_OK, "got %08x\n", hres);
1812 hres = ITypeInfo_GetRefTypeOfImplType(interface1, 0, &hreftype);
1813 ok(hres == S_OK, "got %08x\n", hres);
1814 ok(hreftype == 3, "hreftype = %d\n", hreftype);
1816 hres = ITypeInfo_GetRefTypeInfo(interface1, hreftype, &ti);
1817 ok(hres == S_OK, "got %08x\n", hres);
1819 hres = ITypeInfo_GetTypeAttr(ti, &typeattr);
1820 ok(hres == S_OK, "got %08x\n", hres);
1821 ok(typeattr->cbSizeVft == 3 * ptr_size || broken(sys == SYS_WIN32 && typeattr->cbSizeVft == 24) /* xp64 */,
1822 "retrieved IUnknown gave wrong cbSizeVft: %u\n", typeattr->cbSizeVft);
1823 ITypeInfo_ReleaseTypeAttr(ti, typeattr);
1825 ITypeInfo_Release(ti);
1827 hres = ITypeInfo_GetRefTypeOfImplType(interface1, -1, &hreftype);
1828 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
1830 ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo2, (void**)&ti2);
1832 memset(&funcdesc, 0, sizeof(FUNCDESC));
1833 funcdesc.funckind = FUNC_PUREVIRTUAL;
1834 funcdesc.invkind = INVOKE_PROPERTYGET;
1835 funcdesc.callconv = CC_STDCALL;
1836 funcdesc.elemdescFunc.tdesc.vt = VT_BSTR;
1837 U(funcdesc.elemdescFunc).idldesc.wIDLFlags = IDLFLAG_NONE;
1839 hres = ICreateTypeInfo_AddFuncDesc(createti, 0, NULL);
1840 ok(hres == E_INVALIDARG, "got %08x\n", hres);
1842 hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc);
1843 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
1845 hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc);
1846 ok(hres == S_OK, "got %08x\n", hres);
1848 hres = ITypeInfo2_GetFuncDesc(ti2, 0, NULL);
1849 ok(hres == E_INVALIDARG, "got %08x\n", hres);
1851 hres = ITypeInfo2_GetFuncDesc(ti2, 1, &pfuncdesc);
1852 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
1854 hres = ITypeInfo2_GetFuncDesc(ti2, 0, &pfuncdesc);
1855 ok(hres == S_OK, "got %08x\n", hres);
1857 ok(pfuncdesc->memid == 0, "got %x\n", pfuncdesc->memid);
1858 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
1859 ok(pfuncdesc->lprgelemdescParam == NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
1860 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
1861 ok(pfuncdesc->invkind == INVOKE_PROPERTYGET, "got 0x%x\n", pfuncdesc->invkind);
1862 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
1863 ok(pfuncdesc->cParams == 0, "got %d\n", pfuncdesc->cParams);
1864 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
1865 ok(pfuncdesc->oVft == 3 * ptr_size || broken(sys == SYS_WIN32 && pfuncdesc->oVft == 24) /* xp64 */,
1866 "got %d\n", pfuncdesc->oVft);
1867 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
1868 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_BSTR, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
1869 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
1871 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
1873 hres = ICreateTypeInfo_SetFuncHelpContext(createti, 0, 0xabcdefab);
1874 ok(hres == S_OK, "got %08x\n", hres);
1876 funcdesc.invkind = INVOKE_PROPERTYPUT;
1877 hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc);
1878 ok(hres == TYPE_E_INCONSISTENTPROPFUNCS, "got %08x\n", hres);
1880 funcdesc.invkind = INVOKE_PROPERTYPUTREF;
1881 hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc);
1882 ok(hres == TYPE_E_INCONSISTENTPROPFUNCS, "got %08x\n", hres);
1884 elemdesc[0].tdesc.vt = VT_BSTR;
1885 U(elemdesc[0]).idldesc.dwReserved = 0;
1886 U(elemdesc[0]).idldesc.wIDLFlags = IDLFLAG_FIN;
1888 funcdesc.lprgelemdescParam = elemdesc;
1889 funcdesc.invkind = INVOKE_PROPERTYPUT;
1890 funcdesc.cParams = 1;
1891 funcdesc.elemdescFunc.tdesc.vt = VT_VOID;
1893 hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc);
1894 ok(hres == S_OK, "got %08x\n", hres);
1896 hres = ICreateTypeInfo_SetFuncHelpContext(createti, 1, 0xabcdefab);
1897 ok(hres == S_OK, "got %08x\n", hres);
1899 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, propname, 0);
1900 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
1902 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, NULL, 1);
1903 ok(hres == E_INVALIDARG, "got %08x\n", hres);
1905 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, propname, 1);
1906 ok(hres == S_OK, "got %08x\n", hres);
1908 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 1, propname, 1);
1909 ok(hres == S_OK, "got %08x\n", hres);
1911 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 1, propname, 2);
1912 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
1914 hres = ITypeInfo2_GetFuncDesc(ti2, 1, &pfuncdesc);
1915 ok(hres == S_OK, "got %08x\n", hres);
1917 ok(pfuncdesc->memid == 0, "got %x\n", pfuncdesc->memid);
1918 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
1919 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
1920 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
1921 ok(pfuncdesc->invkind == INVOKE_PROPERTYPUT, "got 0x%x\n", pfuncdesc->invkind);
1922 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
1923 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
1924 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
1925 ok(pfuncdesc->oVft == 4 * ptr_size || broken(sys == SYS_WIN32 && pfuncdesc->oVft == 28) /* xp64 */,
1926 "got %d\n", pfuncdesc->oVft);
1927 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
1928 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
1929 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
1931 edesc = pfuncdesc->lprgelemdescParam;
1932 ok(edesc->tdesc.vt == VT_BSTR, "got: %d\n", edesc->tdesc.vt);
1933 ok(U(*edesc).idldesc.wIDLFlags == IDLFLAG_FIN, "got: %x\n", U(*edesc).idldesc.wIDLFlags);
1935 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
1938 funcdesc.invkind = INVOKE_PROPERTYPUTREF;
1939 hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc);
1940 ok(hres == S_OK, "got %08x\n", hres);
1942 hres = ICreateTypeInfo_SetFuncHelpContext(createti, 0, 0xabcdefab);
1943 ok(hres == S_OK, "got %08x\n", hres);
1945 hres = ICreateTypeInfo_SetFuncHelpContext(createti, 0, 0x201);
1946 ok(hres == S_OK, "got %08x\n", hres);
1948 funcdesc.memid = 1;
1949 funcdesc.lprgelemdescParam = NULL;
1950 funcdesc.invkind = INVOKE_FUNC;
1951 funcdesc.cParams = 0;
1952 hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc);
1953 ok(hres == S_OK, "got %08x\n", hres);
1955 hres = ITypeInfo2_GetFuncDesc(ti2, 1, &pfuncdesc);
1956 ok(hres == S_OK, "got %08x\n", hres);
1958 ok(pfuncdesc->memid == 1, "got %d\n", pfuncdesc->memid);
1959 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
1960 ok(pfuncdesc->lprgelemdescParam == NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
1961 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
1962 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
1963 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
1964 ok(pfuncdesc->cParams == 0, "got %d\n", pfuncdesc->cParams);
1965 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
1966 ok(pfuncdesc->oVft == 4 * ptr_size || broken(sys == SYS_WIN32 && pfuncdesc->oVft == 28), /* xp64 */
1967 "got %d\n", pfuncdesc->oVft);
1968 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
1969 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
1970 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
1972 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
1974 funcdesc.memid = MEMBERID_NIL;
1975 hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc);
1976 ok(hres == S_OK, "got %08x\n", hres);
1978 elemdesc[0].tdesc.vt = VT_PTR;
1979 U(elemdesc[0].tdesc).lptdesc = &typedesc1;
1980 typedesc1.vt = VT_BSTR;
1981 funcdesc.cParams = 1;
1982 funcdesc.lprgelemdescParam = elemdesc;
1983 hres = ICreateTypeInfo_AddFuncDesc(createti, 4, &funcdesc);
1984 ok(hres == S_OK, "got %08x\n", hres);
1986 hres = ITypeInfo2_GetFuncDesc(ti2, 4, &pfuncdesc);
1987 ok(hres == S_OK, "got %08x\n", hres);
1989 ok(pfuncdesc->memid == 0x60010004, "got %x\n", pfuncdesc->memid);
1990 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
1991 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
1992 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
1993 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
1994 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
1995 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
1996 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
1997 ok(pfuncdesc->oVft == 7 * ptr_size || broken(sys == SYS_WIN32 && pfuncdesc->oVft == 40) /* xp64 */,
1998 "got %d\n", pfuncdesc->oVft);
1999 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2000 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2001 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2003 edesc = pfuncdesc->lprgelemdescParam;
2004 ok(edesc->tdesc.vt == VT_PTR, "got: %d\n", edesc->tdesc.vt);
2005 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FIN, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2006 ok(U(*edesc).paramdesc.pparamdescex == NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2007 ok(U(edesc->tdesc).lptdesc != NULL, "got: %p\n", U(edesc->tdesc).lptdesc);
2008 ok(U(edesc->tdesc).lptdesc->vt == VT_BSTR, "got: %d\n", U(edesc->tdesc).lptdesc->vt);
2010 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2012 U(elemdesc[0].tdesc).lptdesc = &typedesc2;
2013 typedesc2.vt = VT_PTR;
2014 U(typedesc2).lptdesc = &typedesc1;
2015 hres = ICreateTypeInfo_AddFuncDesc(createti, 4, &funcdesc);
2016 ok(hres == S_OK, "got %08x\n", hres);
2018 hres = ITypeInfo2_GetFuncDesc(ti2, 4, &pfuncdesc);
2019 ok(hres == S_OK, "got %08x\n", hres);
2021 ok(pfuncdesc->memid == 0x60010007, "got %x\n", pfuncdesc->memid);
2022 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2023 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2024 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2025 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2026 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2027 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2028 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2029 ok(pfuncdesc->oVft == 7 * ptr_size || broken(sys == SYS_WIN32 && pfuncdesc->oVft == 40) /* xp64 */,
2030 "got %d\n", pfuncdesc->oVft);
2031 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2032 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2033 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2035 edesc = pfuncdesc->lprgelemdescParam;
2036 ok(edesc->tdesc.vt == VT_PTR, "got: %d\n", edesc->tdesc.vt);
2037 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FIN, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2038 ok(U(*edesc).paramdesc.pparamdescex == NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2039 ok(U(edesc->tdesc).lptdesc != NULL, "got: %p\n", U(edesc->tdesc).lptdesc);
2040 ok(U(edesc->tdesc).lptdesc->vt == VT_PTR, "got: %d\n", U(edesc->tdesc).lptdesc->vt);
2041 ok(U(*U(edesc->tdesc).lptdesc).lptdesc != NULL, "got: %p\n", U(*U(edesc->tdesc).lptdesc).lptdesc);
2042 ok(U(*U(edesc->tdesc).lptdesc).lptdesc->vt == VT_BSTR, "got: %d\n", U(*U(edesc->tdesc).lptdesc).lptdesc->vt);
2044 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2046 elemdesc[0].tdesc.vt = VT_INT;
2047 U(elemdesc[0]).paramdesc.wParamFlags = PARAMFLAG_FHASDEFAULT;
2048 U(elemdesc[0]).paramdesc.pparamdescex = &paramdescex;
2049 V_VT(&paramdescex.varDefaultValue) = VT_INT;
2050 V_INT(&paramdescex.varDefaultValue) = 0x123;
2051 hres = ICreateTypeInfo_AddFuncDesc(createti, 3, &funcdesc);
2052 ok(hres == S_OK, "got %08x\n", hres);
2054 hres = ITypeInfo2_GetFuncDesc(ti2, 3, &pfuncdesc);
2055 ok(hres == S_OK, "got %08x\n", hres);
2057 ok(pfuncdesc->memid == 0x60010003, "got %x\n", pfuncdesc->memid);
2058 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2059 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2060 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2061 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2062 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2063 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2064 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2065 ok(pfuncdesc->oVft == 6 * ptr_size || broken(sys == SYS_WIN32 && pfuncdesc->oVft == 36) /* xp64 */,
2066 "got %d\n", pfuncdesc->oVft);
2067 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2068 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2069 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2071 edesc = pfuncdesc->lprgelemdescParam;
2072 ok(edesc->tdesc.vt == VT_INT, "got: %d\n", edesc->tdesc.vt);
2073 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2074 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2075 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
2076 U(*edesc).paramdesc.pparamdescex->cBytes);
2077 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_I4, "got: %d\n",
2078 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2079 ok(V_I4(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0x123, "got: 0x%x\n",
2080 V_I4(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2082 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2084 U(elemdesc[0]).idldesc.dwReserved = 0;
2085 U(elemdesc[0]).idldesc.wIDLFlags = IDLFLAG_FIN;
2086 elemdesc[1].tdesc.vt = VT_UI2;
2087 U(elemdesc[1]).paramdesc.wParamFlags = PARAMFLAG_FHASDEFAULT;
2088 U(elemdesc[1]).paramdesc.pparamdescex = &paramdescex;
2089 V_VT(&paramdescex.varDefaultValue) = VT_UI2;
2090 V_UI2(&paramdescex.varDefaultValue) = 0xffff;
2091 funcdesc.cParams = 2;
2092 hres = ICreateTypeInfo_AddFuncDesc(createti, 3, &funcdesc);
2093 ok(hres == S_OK, "got %08x\n", hres);
2095 hres = ITypeInfo2_GetFuncDesc(ti2, 3, &pfuncdesc);
2096 ok(hres == S_OK, "got %08x\n", hres);
2098 ok(pfuncdesc->memid == 0x60010009, "got %x\n", pfuncdesc->memid);
2099 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2100 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2101 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2102 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2103 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2104 ok(pfuncdesc->cParams == 2, "got %d\n", pfuncdesc->cParams);
2105 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2106 ok(pfuncdesc->oVft == 6 * ptr_size || broken(sys == SYS_WIN32 && pfuncdesc->oVft == 36) /* xp64 */,
2107 "got %d\n", pfuncdesc->oVft);
2108 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2109 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2110 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2112 edesc = pfuncdesc->lprgelemdescParam;
2113 ok(edesc->tdesc.vt == VT_INT, "got: %d\n", edesc->tdesc.vt);
2114 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FIN, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2115 ok(U(*edesc).paramdesc.pparamdescex == NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2117 edesc = pfuncdesc->lprgelemdescParam + 1;
2118 ok(edesc->tdesc.vt == VT_UI2, "got: %d\n", edesc->tdesc.vt);
2119 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2120 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2121 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
2122 U(*edesc).paramdesc.pparamdescex->cBytes);
2123 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_UI2, "got: %d\n",
2124 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2125 ok(V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0xFFFF, "got: 0x%x\n",
2126 V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2128 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2130 U(elemdesc[0]).paramdesc.wParamFlags = PARAMFLAG_FHASDEFAULT;
2131 U(elemdesc[0]).paramdesc.pparamdescex = &paramdescex;
2132 elemdesc[1].tdesc.vt = VT_INT;
2133 V_VT(&paramdescex.varDefaultValue) = VT_INT;
2134 V_INT(&paramdescex.varDefaultValue) = 0xffffffff;
2135 hres = ICreateTypeInfo_AddFuncDesc(createti, 3, &funcdesc);
2136 ok(hres == S_OK, "got %08x\n", hres);
2138 elemdesc[0].tdesc.vt = VT_BSTR;
2139 elemdesc[1].tdesc.vt = VT_BSTR;
2140 V_VT(&paramdescex.varDefaultValue) = VT_BSTR;
2141 V_BSTR(&paramdescex.varDefaultValue) = SysAllocString(defaultW);
2142 hres = ICreateTypeInfo_AddFuncDesc(createti, 3, &funcdesc);
2143 ok(hres == S_OK, "got %08x\n", hres);
2144 SysFreeString(V_BSTR(&paramdescex.varDefaultValue));
2146 hres = ITypeInfo2_GetFuncDesc(ti2, 3, &pfuncdesc);
2147 ok(hres == S_OK, "got %08x\n", hres);
2149 ok(pfuncdesc->memid == 0x6001000b, "got %x\n", pfuncdesc->memid);
2150 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2151 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2152 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2153 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2154 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2155 ok(pfuncdesc->cParams == 2, "got %d\n", pfuncdesc->cParams);
2156 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2157 ok(pfuncdesc->oVft == 6 * ptr_size || broken(sys == SYS_WIN32 && pfuncdesc->oVft == 36) /* xp64 */,
2158 "got %d\n", pfuncdesc->oVft);
2159 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2160 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2161 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2163 edesc = pfuncdesc->lprgelemdescParam;
2164 ok(edesc->tdesc.vt == VT_BSTR, "got: %d\n", edesc->tdesc.vt);
2165 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2166 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2167 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
2168 U(*edesc).paramdesc.pparamdescex->cBytes);
2169 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_BSTR, "got: %d\n",
2170 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2171 ok(!lstrcmpW(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue), defaultQW),
2172 "got: %s\n",
2173 wine_dbgstr_w(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue)));
2175 edesc = pfuncdesc->lprgelemdescParam + 1;
2176 ok(edesc->tdesc.vt == VT_BSTR, "got: %d\n", edesc->tdesc.vt);
2177 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2178 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2179 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
2180 U(*edesc).paramdesc.pparamdescex->cBytes);
2181 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_BSTR, "got: %d\n",
2182 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2183 ok(!lstrcmpW(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue), defaultQW),
2184 "got: %s\n",
2185 wine_dbgstr_w(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue)));
2187 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2189 elemdesc[0].tdesc.vt = VT_USERDEFINED;
2190 U(elemdesc[0].tdesc).hreftype = hreftype;
2191 U(elemdesc[0]).paramdesc.pparamdescex = &paramdescex;
2192 U(elemdesc[0]).paramdesc.wParamFlags = PARAMFLAG_FHASDEFAULT;
2193 V_VT(&paramdescex.varDefaultValue) = VT_INT;
2194 V_INT(&paramdescex.varDefaultValue) = 0x789;
2196 funcdesc.lprgelemdescParam = elemdesc;
2197 funcdesc.invkind = INVOKE_FUNC;
2198 funcdesc.cParams = 1;
2199 funcdesc.elemdescFunc.tdesc.vt = VT_VOID;
2201 hres = ICreateTypeInfo_AddFuncDesc(createti, 5, &funcdesc);
2202 ok(hres == S_OK, "got %08x\n", hres);
2204 hres = ITypeInfo2_GetFuncDesc(ti2, 5, &pfuncdesc);
2205 ok(hres == S_OK, "got %08x\n", hres);
2207 ok(pfuncdesc->memid == 0x60010005, "got %x\n", pfuncdesc->memid);
2208 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2209 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2210 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2211 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2212 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2213 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2214 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2215 ok(pfuncdesc->oVft == 8 * ptr_size || broken(sys == SYS_WIN32 && pfuncdesc->oVft == 44), /* xp64 */
2216 "got %d\n", pfuncdesc->oVft);
2217 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2218 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2219 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2221 edesc = pfuncdesc->lprgelemdescParam;
2222 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2223 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT,
2224 "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2225 ok(edesc->tdesc.vt == VT_USERDEFINED, "got: %d\n", edesc->tdesc.vt);
2226 ok(U(edesc->tdesc).hreftype == hreftype, "got: 0x%x\n", U(edesc->tdesc).hreftype);
2227 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_INT, "got: %d\n",
2228 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2229 ok(V_INT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0x789, "got: %d\n",
2230 V_INT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2232 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2234 elemdesc[0].tdesc.vt = VT_VARIANT;
2235 U(elemdesc[0]).paramdesc.pparamdescex = &paramdescex;
2236 U(elemdesc[0]).paramdesc.wParamFlags = PARAMFLAG_FHASDEFAULT;
2237 V_VT(&paramdescex.varDefaultValue) = VT_INT;
2238 V_INT(&paramdescex.varDefaultValue) = 3;
2240 funcdesc.lprgelemdescParam = elemdesc;
2241 funcdesc.invkind = INVOKE_FUNC;
2242 funcdesc.cParams = 1;
2243 funcdesc.elemdescFunc.tdesc.vt = VT_VARIANT;
2245 hres = ICreateTypeInfo_AddFuncDesc(createti, 6, &funcdesc);
2246 ok(hres == S_OK, "got %08x\n", hres);
2248 hres = ITypeInfo2_GetFuncDesc(ti2, 6, &pfuncdesc);
2249 ok(hres == S_OK, "got %08x\n", hres);
2251 ok(pfuncdesc->memid == 0x60010006, "got %x\n", pfuncdesc->memid);
2252 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2253 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2254 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2255 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2256 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2257 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2258 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2259 ok(pfuncdesc->oVft == 9 * ptr_size || broken(sys == SYS_WIN32 && pfuncdesc->oVft == 48), /* xp64 */
2260 "got %d\n", pfuncdesc->oVft);
2261 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2262 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VARIANT, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2263 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2265 edesc = pfuncdesc->lprgelemdescParam;
2266 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2267 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT,
2268 "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2269 ok(edesc->tdesc.vt == VT_VARIANT, "got: %d\n", edesc->tdesc.vt);
2270 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_INT, "got: %d\n",
2271 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2272 ok(V_INT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 3, "got: %d\n",
2273 V_INT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2275 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2277 hres = ITypeInfo_GetDocumentation(interface1, 0, &name, &docstring, &helpcontext, &helpfile);
2278 ok(hres == S_OK, "got %08x\n", hres);
2279 ok(name == NULL, "name != NULL\n");
2280 ok(docstring == NULL, "docstring != NULL\n");
2281 ok(helpcontext == 0x201, "helpcontext != 0x201\n");
2282 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "helpfile = %s\n", wine_dbgstr_w(helpfile));
2284 SysFreeString(helpfile);
2286 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 1000, NULL, 1);
2287 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2289 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 1000, names1, 1);
2290 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2292 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, names1, 2);
2293 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2295 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, names2, 1);
2296 ok(hres == S_OK, "got %08x\n", hres);
2298 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, names1, 1);
2299 ok(hres == S_OK, "got %08x\n", hres);
2301 hres = ITypeInfo_GetDocumentation(interface1, 0, &name, NULL, NULL, NULL);
2302 ok(hres == S_OK, "got %08x\n", hres);
2303 ok(!memcmp(name, func1W, sizeof(func1W)), "name = %s\n", wine_dbgstr_w(name));
2305 SysFreeString(name);
2307 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 3, names2, 3);
2308 ok(hres == S_OK, "got %08x\n", hres);
2310 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 3, names1, 3);
2311 ok(hres == TYPE_E_AMBIGUOUSNAME, "got %08x\n", hres);
2313 ITypeInfo2_Release(ti2);
2314 ICreateTypeInfo_Release(createti);
2316 hres = ICreateTypeLib2_CreateTypeInfo(createtl, interface1W, TKIND_INTERFACE, &createti);
2317 ok(hres == TYPE_E_NAMECONFLICT, "got %08x\n", hres);
2319 hres = ICreateTypeLib2_CreateTypeInfo(createtl, interface2W, TKIND_INTERFACE, &createti);
2320 ok(hres == S_OK, "got %08x\n", hres);
2322 hres = ICreateTypeInfo_SetGuid(createti, &interface2guid);
2323 ok(hres == S_OK, "got %08x\n", hres);
2325 hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&interface2);
2326 ok(hres == S_OK, "got %08x\n", hres);
2328 hres = ITypeInfo_GetRefTypeOfImplType(interface2, 0, &hreftype);
2329 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2331 hres = ICreateTypeInfo_AddRefTypeInfo(createti, interface1, &hreftype);
2332 ok(hres == S_OK, "got %08x\n", hres);
2334 hres = ITypeInfo_GetRefTypeInfo(interface2, 0, &ti);
2335 ok(hres == S_OK, "got %08x\n", hres);
2336 ok(ti == interface1, "Received and added interfaces are different\n");
2338 ITypeInfo_Release(ti);
2340 hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype);
2341 ok(hres == S_OK, "got %08x\n", hres);
2343 hres = ITypeInfo_GetRefTypeOfImplType(interface2, 0, &hreftype);
2344 ok(hres == S_OK, "got %08x\n", hres);
2345 ok(hreftype == 2, "hreftype = %d\n", hreftype);
2347 hres = ITypeInfo_GetRefTypeOfImplType(interface2, -1, &hreftype);
2348 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2350 hres = ICreateTypeInfo_SetImplTypeFlags(createti, 0, IMPLTYPEFLAG_FDEFAULT);
2351 ok(hres == TYPE_E_BADMODULEKIND, "got %08x\n", hres);
2353 hres = ITypeInfo_GetImplTypeFlags(interface2, 0, &impltypeflags);
2354 ok(hres == S_OK, "got %08x\n", hres);
2355 ok(impltypeflags == 0, "impltypeflags = %x\n", impltypeflags);
2357 hres = ITypeInfo_GetImplTypeFlags(interface2, 1, &impltypeflags);
2358 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2360 funcdesc.elemdescFunc.tdesc.vt = VT_VOID;
2361 funcdesc.oVft = 0xaaac;
2362 hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc);
2363 if(sys == SYS_WIN64){
2364 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2365 funcdesc.oVft = 0xaab0;
2366 hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc);
2368 ok(hres == S_OK, "got %08x\n", hres);
2369 funcdesc.oVft = 0xaaa8;
2370 hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc);
2371 ok(hres == S_OK, "got %08x\n", hres);
2373 hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&ti2);
2374 ok(hres == S_OK, "got %08x\n", hres);
2376 hres = ITypeInfo2_GetFuncDesc(ti2, 0, &pfuncdesc);
2377 ok(hres == S_OK, "got %08x\n", hres);
2379 ok(pfuncdesc->memid == 0x60020000, "got %x\n", pfuncdesc->memid);
2380 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2381 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2382 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2383 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2384 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2385 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2386 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2387 ok(pfuncdesc->oVft == (short)0xaaa8, "got %d\n", pfuncdesc->oVft);
2388 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2389 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2390 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2392 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2393 ITypeInfo2_Release(ti2);
2395 funcdesc.oVft = 0;
2397 ICreateTypeInfo_Release(createti);
2399 VariantInit(&cust_data);
2401 hres = ICreateTypeLib2_CreateTypeInfo(createtl, interface3W, TKIND_INTERFACE, &createti);
2402 ok(hres == S_OK, "got %08x\n", hres);
2404 hres = ICreateTypeInfo_QueryInterface(createti, &IID_ICreateTypeInfo2, (void**)&createti2);
2405 ok(hres == S_OK, "got %08x\n", hres);
2407 hres = ICreateTypeInfo2_QueryInterface(createti2, &IID_ITypeInfo2, (void**)&ti2);
2408 ok(hres == S_OK, "got %08x\n", hres);
2410 hres = ITypeInfo2_GetCustData(ti2, NULL, NULL);
2411 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2413 hres = ITypeInfo2_GetCustData(ti2, &custguid, NULL);
2414 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2416 hres = ITypeInfo2_GetCustData(ti2, &custguid, &cust_data);
2417 ok(hres == S_OK, "got %08x\n", hres);
2419 hres = ICreateTypeInfo2_SetCustData(createti2, NULL, NULL);
2420 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2422 hres = ICreateTypeInfo2_SetCustData(createti2, &custguid, NULL);
2423 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2425 hres = ICreateTypeInfo2_SetCustData(createti2, &custguid, &cust_data);
2426 ok(hres == DISP_E_BADVARTYPE, "got %08x\n", hres);
2428 V_VT(&cust_data) = VT_UI4;
2429 V_I4(&cust_data) = 0xdeadbeef;
2431 hres = ICreateTypeInfo2_SetCustData(createti2, &custguid, &cust_data);
2432 ok(hres == S_OK, "got %08x\n", hres);
2434 V_I4(&cust_data) = 0;
2435 V_VT(&cust_data) = VT_EMPTY;
2437 hres = ITypeInfo2_GetCustData(ti2, &custguid, &cust_data);
2438 ok(hres == S_OK, "got %08x\n", hres);
2440 ok(V_VT(&cust_data) == VT_UI4, "got %d\n", V_VT(&cust_data));
2441 ok(V_I4(&cust_data) == 0xdeadbeef, "got 0x%08x\n", V_I4(&cust_data));
2443 V_VT(&cust_data) = VT_UI4;
2444 V_I4(&cust_data) = 12345678;
2446 hres = ICreateTypeInfo2_SetCustData(createti2, &custguid, &cust_data);
2447 ok(hres == S_OK, "got %08x\n", hres);
2449 V_I4(&cust_data) = 0;
2450 V_VT(&cust_data) = VT_EMPTY;
2452 hres = ITypeInfo2_GetCustData(ti2, &custguid, &cust_data);
2453 ok(hres == S_OK, "got %08x\n", hres);
2455 ok(V_VT(&cust_data) == VT_UI4, "got %d\n", V_VT(&cust_data));
2456 ok(V_I4(&cust_data) == 12345678, "got 0x%08x\n", V_I4(&cust_data));
2458 V_VT(&cust_data) = VT_BSTR;
2459 V_BSTR(&cust_data) = SysAllocString(asdfW);
2461 hres = ICreateTypeInfo2_SetCustData(createti2, &custguid, &cust_data);
2462 ok(hres == S_OK, "got %08x\n", hres);
2464 SysFreeString(V_BSTR(&cust_data));
2465 V_I4(&cust_data) = 0;
2466 V_VT(&cust_data) = VT_EMPTY;
2468 hres = ITypeInfo2_GetCustData(ti2, &custguid, &cust_data);
2469 ok(hres == S_OK, "got %08x\n", hres);
2471 ok(V_VT(&cust_data) == VT_BSTR, "got %d\n", V_VT(&cust_data));
2472 ok(!lstrcmpW(V_BSTR(&cust_data), asdfW), "got %s\n", wine_dbgstr_w(V_BSTR(&cust_data)));
2473 SysFreeString(V_BSTR(&cust_data));
2475 V_VT(&cust_data) = VT_UI4;
2476 V_UI4(&cust_data) = 17;
2478 hres = ITypeInfo2_GetCustData(ti2, &bogusguid, &cust_data);
2479 ok(hres == S_OK, "got %08x\n", hres);
2481 ok(V_VT(&cust_data) == VT_EMPTY, "got: %d\n", V_VT(&cust_data));
2483 ITypeInfo2_Release(ti2);
2484 ICreateTypeInfo2_Release(createti2);
2485 ICreateTypeInfo_Release(createti);
2487 hres = ICreateTypeLib2_CreateTypeInfo(createtl, coclassW, TKIND_COCLASS, &createti);
2488 ok(hres == S_OK, "got %08x\n", hres);
2490 hres = ICreateTypeInfo_AddRefTypeInfo(createti, interface1, &hreftype);
2491 ok(hres == S_OK, "got %08x\n", hres);
2493 hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype);
2494 ok(hres == S_OK, "got %08x\n", hres);
2496 hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype);
2497 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2499 hres = ICreateTypeInfo_AddRefTypeInfo(createti, unknown, &hreftype);
2500 ok(hres == S_OK, "got %08x\n", hres);
2502 hres = ICreateTypeInfo_AddImplType(createti, 1, hreftype);
2503 ok(hres == S_OK, "got %08x\n", hres);
2505 hres = ICreateTypeInfo_AddImplType(createti, 1, hreftype);
2506 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2508 hres = ICreateTypeInfo_AddImplType(createti, 2, hreftype);
2509 ok(hres == S_OK, "got %08x\n", hres);
2511 hres = ICreateTypeInfo_SetImplTypeFlags(createti, 0, IMPLTYPEFLAG_FDEFAULT);
2512 ok(hres == S_OK, "got %08x\n", hres);
2514 hres = ICreateTypeInfo_SetImplTypeFlags(createti, 1, IMPLTYPEFLAG_FRESTRICTED);
2515 ok(hres == S_OK, "got %08x\n", hres);
2517 hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&ti);
2518 ok(hres == S_OK, "got %08x\n", hres);
2520 hres = ITypeInfo_GetImplTypeFlags(ti, 0, NULL);
2521 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2523 hres = ITypeInfo_GetImplTypeFlags(ti, 0, &impltypeflags);
2524 ok(hres == S_OK, "got %08x\n", hres);
2525 ok(impltypeflags == IMPLTYPEFLAG_FDEFAULT, "impltypeflags = %x\n", impltypeflags);
2527 hres = ITypeInfo_GetImplTypeFlags(ti, 1, &impltypeflags);
2528 ok(hres == S_OK, "got %08x\n", hres);
2529 ok(impltypeflags == IMPLTYPEFLAG_FRESTRICTED, "impltypeflags = %x\n", impltypeflags);
2531 hres = ITypeInfo_GetImplTypeFlags(ti, 2, &impltypeflags);
2532 ok(hres == S_OK, "got %08x\n", hres);
2533 ok(impltypeflags == 0, "impltypeflags = %x\n", impltypeflags);
2535 hres = ITypeInfo_GetRefTypeOfImplType(ti, 0, &hreftype);
2536 ok(hres == S_OK, "got %08x\n", hres);
2537 ok(hreftype == 0, "hreftype = %d\n", hreftype);
2539 hres = ITypeInfo_GetRefTypeOfImplType(ti, 1, &hreftype);
2540 ok(hres == S_OK, "got %08x\n", hres);
2541 ok(hreftype == 1, "hreftype = %d\n", hreftype);
2543 hres = ITypeInfo_GetRefTypeOfImplType(ti, 2, &hreftype);
2544 ok(hres == S_OK, "got %08x\n", hres);
2545 ok(hreftype == 1, "hreftype = %d\n", hreftype);
2547 hres = ITypeInfo_GetRefTypeOfImplType(ti, -1, &hreftype);
2548 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2550 ITypeInfo_Release(ti);
2552 ICreateTypeInfo_Release(createti);
2554 hres = ICreateTypeLib2_CreateTypeInfo(createtl, dualW, TKIND_INTERFACE, &createti);
2555 ok(hres == S_OK, "got %08x\n", hres);
2557 hres = ICreateTypeInfo_SetTypeFlags(createti, TYPEFLAG_FDUAL);
2558 ok(hres == S_OK, "got %08x\n", hres);
2560 hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc);
2561 ok(hres == S_OK, "got %08x\n", hres);
2563 hres = ICreateTypeInfo_AddRefTypeInfo(createti, dispatch, &hreftype);
2564 ok(hres == S_OK, "got %08x\n", hres);
2566 hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype);
2567 ok(hres == S_OK, "got %08x\n", hres);
2569 hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&dual);
2570 ok(hres == S_OK, "got %08x\n", hres);
2572 hres = ITypeInfo_GetTypeAttr(dual, &typeattr);
2573 ok(hres == S_OK, "got %08x\n", hres);
2574 ok(typeattr->cbSizeInstance == ptr_size, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2575 ok(typeattr->typekind == 3, "typekind = %d\n", typeattr->typekind);
2576 ok(typeattr->cFuncs == 1, "cFuncs = %d\n", typeattr->cFuncs);
2577 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2578 ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
2579 ok(typeattr->cbSizeVft == 8 * ptr_size || broken(sys == SYS_WIN32 && typeattr->cbSizeVft == 7 * sizeof(void *) + 4), /* xp64 */
2580 "cbSizeVft = %d\n", typeattr->cbSizeVft);
2581 ok(typeattr->cbAlignment == 4, "cbAlignment = %d\n", typeattr->cbAlignment);
2582 ok(typeattr->wTypeFlags == (TYPEFLAG_FDISPATCHABLE|TYPEFLAG_FDUAL), "wTypeFlags = %d\n", typeattr->wTypeFlags);
2583 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2584 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2586 ITypeInfo_ReleaseTypeAttr(dual, typeattr);
2588 hres = ITypeInfo_GetRefTypeOfImplType(dual, -1, &hreftype);
2589 ok(hres == S_OK, "got %08x\n", hres);
2590 ok(hreftype == -2, "got %08x\n", hreftype);
2592 hres = ITypeInfo_GetRefTypeInfo(dual, -2, &ti);
2593 ok(hres == S_OK, "got %08x\n", hres);
2595 hres = ITypeInfo_GetTypeAttr(ti, &typeattr);
2596 ok(hres == S_OK, "got %08x\n", hres);
2597 ok(typeattr->cbSizeInstance == ptr_size, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2598 ok(typeattr->typekind == 4, "typekind = %d\n", typeattr->typekind);
2599 ok(typeattr->cFuncs == 8, "cFuncs = %d\n", typeattr->cFuncs);
2600 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2601 ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
2602 ok(typeattr->cbSizeVft == 7 * sizeof(void *), "cbSizeVft = %d\n", typeattr->cbSizeVft);
2603 ok(typeattr->cbAlignment == 4, "cbAlignment = %d\n", typeattr->cbAlignment);
2604 ok(typeattr->wTypeFlags == (TYPEFLAG_FDISPATCHABLE|TYPEFLAG_FDUAL), "wTypeFlags = %d\n", typeattr->wTypeFlags);
2605 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2606 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2608 ITypeInfo_ReleaseTypeAttr(ti, typeattr);
2610 ITypeInfo_Release(ti);
2612 hres = ICreateTypeInfo_SetTypeDescAlias(createti, &typedesc1);
2613 ok(hres == TYPE_E_BADMODULEKIND, "got %08x\n", hres);
2615 ICreateTypeInfo_Release(createti);
2617 hres = ITypeInfo_GetTypeAttr(interface1, &typeattr);
2618 ok(hres == S_OK, "got %08x\n", hres);
2619 ok(typeattr->cbSizeInstance == ptr_size, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2620 ok(typeattr->typekind == 3, "typekind = %d\n", typeattr->typekind);
2621 ok(typeattr->cFuncs == 13, "cFuncs = %d\n", typeattr->cFuncs);
2622 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2623 ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
2624 ok(typeattr->cbSizeVft == 16 * ptr_size || broken(sys == SYS_WIN32 && typeattr->cbSizeVft == 3 * sizeof(void *) + 52), /* xp64 */
2625 "cbSizeVft = %d\n", typeattr->cbSizeVft);
2626 ok(typeattr->cbAlignment == 4, "cbAlignment = %d\n", typeattr->cbAlignment);
2627 ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
2628 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2629 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2631 ITypeInfo_ReleaseTypeAttr(interface1, typeattr);
2633 hres = ITypeInfo_GetTypeAttr(interface2, &typeattr);
2634 ok(hres == S_OK, "got %08x\n", hres);
2635 ok(typeattr->cbSizeInstance == ptr_size, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2636 ok(typeattr->typekind == 3, "typekind = %d\n", typeattr->typekind);
2637 ok(typeattr->cFuncs == 2, "cFuncs = %d\n", typeattr->cFuncs);
2638 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2639 ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
2640 ok((sys == SYS_WIN32 && typeattr->cbSizeVft == 0xaab0) ||
2641 (sys == SYS_WIN64 && typeattr->cbSizeVft == 0xaab8),
2642 "cbSizeVft = 0x%x\n", typeattr->cbSizeVft);
2643 ok(typeattr->cbAlignment == 4, "cbAlignment = %d\n", typeattr->cbAlignment);
2644 ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
2645 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2646 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2648 ITypeInfo_ReleaseTypeAttr(interface2, typeattr);
2650 ok(ITypeInfo_Release(interface2)==0, "Object should be freed\n");
2651 ok(ITypeInfo_Release(interface1)==0, "Object should be freed\n");
2652 ok(ITypeInfo_Release(dual)==0, "Object should be freed\n");
2654 hres = ICreateTypeLib2_CreateTypeInfo(createtl, aliasW, TKIND_ALIAS, &createti);
2655 ok(hres == S_OK, "got %08x\n", hres);
2657 hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&interface1);
2658 ok(hres == S_OK, "got %08x\n", hres);
2660 if(0){
2661 /* windows gives invalid values here, and even breaks the typeinfo permanently
2662 * on winxp. only call GetTypeAttr() on a TKIND_ALIAS after SetTypeDescAlias. */
2663 hres = ITypeInfo_GetTypeAttr(interface1, &typeattr);
2664 ok(hres == S_OK, "got %08x\n", hres);
2665 ok(typeattr->cbSizeInstance == 0xffffffb4, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2666 ok(typeattr->typekind == TKIND_ALIAS, "typekind = %d\n", typeattr->typekind);
2667 ok(typeattr->cFuncs == 0, "cFuncs = %d\n", typeattr->cFuncs);
2668 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2669 ok(typeattr->cImplTypes == 0, "cImplTypes = %d\n", typeattr->cImplTypes);
2670 ok(typeattr->cbSizeVft == 0, "cbSizeVft = %d\n", typeattr->cbSizeVft);
2671 ok(typeattr->cbAlignment == 0, "cbAlignment = %d\n", typeattr->cbAlignment);
2672 ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
2673 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2674 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2675 ok(typeattr->tdescAlias.vt == VT_EMPTY, "Got wrong tdescAlias.vt: %u\n", typeattr->tdescAlias.vt);
2676 ITypeInfo_ReleaseTypeAttr(interface1, typeattr);
2679 hres = ICreateTypeInfo_SetTypeDescAlias(createti, NULL);
2680 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2682 typedesc1.vt = VT_I1;
2683 hres = ICreateTypeInfo_SetTypeDescAlias(createti, &typedesc1);
2684 ok(hres == S_OK, "got %08x\n", hres);
2686 hres = ITypeInfo_GetTypeAttr(interface1, &typeattr);
2687 ok(hres == S_OK, "got %08x\n", hres);
2688 ok(typeattr->cbSizeInstance == 1, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2689 ok(typeattr->typekind == TKIND_ALIAS, "typekind = %d\n", typeattr->typekind);
2690 ok(typeattr->cFuncs == 0, "cFuncs = %d\n", typeattr->cFuncs);
2691 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2692 ok(typeattr->cImplTypes == 0, "cImplTypes = %d\n", typeattr->cImplTypes);
2693 ok(typeattr->cbSizeVft == 0, "cbSizeVft = %d\n", typeattr->cbSizeVft);
2694 ok(typeattr->cbAlignment == 1, "cbAlignment = %d\n", typeattr->cbAlignment);
2695 ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
2696 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2697 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2698 ok(typeattr->tdescAlias.vt == VT_I1, "Got wrong tdescAlias.vt: %u\n", typeattr->tdescAlias.vt);
2699 ITypeInfo_ReleaseTypeAttr(interface1, typeattr);
2701 typedesc1.vt = VT_R8;
2702 hres = ICreateTypeInfo_SetTypeDescAlias(createti, &typedesc1);
2703 ok(hres == S_OK, "got %08x\n", hres);
2705 hres = ITypeInfo_GetTypeAttr(interface1, &typeattr);
2706 ok(hres == S_OK, "got %08x\n", hres);
2707 ok(typeattr->cbSizeInstance == 8, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2708 ok(typeattr->typekind == TKIND_ALIAS, "typekind = %d\n", typeattr->typekind);
2709 ok(typeattr->cFuncs == 0, "cFuncs = %d\n", typeattr->cFuncs);
2710 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2711 ok(typeattr->cImplTypes == 0, "cImplTypes = %d\n", typeattr->cImplTypes);
2712 ok(typeattr->cbSizeVft == 0, "cbSizeVft = %d\n", typeattr->cbSizeVft);
2713 ok(typeattr->cbAlignment == 4, "cbAlignment = %d\n", typeattr->cbAlignment);
2714 ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
2715 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2716 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2717 ok(typeattr->tdescAlias.vt == VT_R8, "Got wrong tdescAlias.vt: %u\n", typeattr->tdescAlias.vt);
2718 ITypeInfo_ReleaseTypeAttr(interface1, typeattr);
2720 ITypeInfo_Release(interface1);
2721 ICreateTypeInfo_Release(createti);
2723 hres = ICreateTypeLib2_SaveAllChanges(createtl);
2724 ok(hres == S_OK, "got %08x\n", hres);
2726 ok(ICreateTypeLib2_Release(createtl)==0, "Object should be freed\n");
2728 ok(ITypeInfo_Release(dispatch)==0, "Object should be freed\n");
2729 ok(ITypeInfo_Release(unknown)==0, "Object should be freed\n");
2730 ok(ITypeLib_Release(stdole)==0, "Object should be freed\n");
2732 hres = LoadTypeLibEx(filenameW, REGKIND_NONE, &tl);
2733 ok(hres == S_OK, "got %08x\n", hres);
2735 hres = ITypeLib_GetLibAttr(tl, &libattr);
2736 ok(hres == S_OK, "got %08x\n", hres);
2737 ok(libattr->syskind == sys, "syskind = %d\n", libattr->syskind);
2738 ok(libattr->wMajorVerNum == 0, "wMajorVer = %d\n", libattr->wMajorVerNum);
2739 ok(libattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", libattr->wMinorVerNum);
2740 ok(libattr->wLibFlags == LIBFLAG_FHASDISKIMAGE, "wLibFlags = %d\n", libattr->wLibFlags);
2741 ITypeLib_ReleaseTLibAttr(tl, libattr);
2743 found = 2;
2744 memset(tinfos, 0, sizeof(tinfos));
2745 memids[0] = 0xdeadbeef;
2746 memids[1] = 0xdeadbeef;
2747 hres = ITypeLib_FindName(tl, param1W, 0, tinfos, memids, &found);
2748 ok(hres == S_OK, "got: %08x\n", hres);
2749 ok(found == 0, "got wrong count: %u\n", found);
2750 ok(tinfos[0] == NULL, "got invalid typeinfo[0]\n");
2751 ok(tinfos[1] == NULL, "got invalid typeinfo[1]\n");
2752 ok(memids[0] == 0xdeadbeef, "got invalid memid[0]\n");
2753 ok(memids[1] == 0xdeadbeef, "got invalid memid[1]\n");
2755 found = 2;
2756 memset(tinfos, 0, sizeof(tinfos));
2757 memids[0] = 0xdeadbeef;
2758 memids[1] = 0xdeadbeef;
2759 hres = ITypeLib_FindName(tl, func1W, 0, tinfos, memids, &found);
2760 ok(hres == S_OK, "got: %08x\n", hres);
2761 ok(found == 1, "got wrong count: %u\n", found);
2762 ok(tinfos[0] != NULL, "got invalid typeinfo[0]\n");
2763 ok(tinfos[1] == NULL, "got invalid typeinfo[1]\n");
2764 ok(memids[0] == 0, "got invalid memid[0]\n");
2765 ok(memids[1] == 0xdeadbeef, "got invalid memid[1]\n");
2766 if(tinfos[0])
2767 ITypeInfo_Release(tinfos[0]);
2769 found = 2;
2770 memset(tinfos, 0, sizeof(tinfos));
2771 memids[0] = 0xdeadbeef;
2772 memids[1] = 0xdeadbeef;
2773 hres = ITypeLib_FindName(tl, interface1W, 0, tinfos, memids, &found);
2774 ok(hres == S_OK, "got: %08x\n", hres);
2775 ok(found == 1, "got wrong count: %u\n", found);
2776 ok(tinfos[0] != NULL, "got invalid typeinfo[0]\n");
2777 ok(tinfos[1] == NULL, "got invalid typeinfo[1]\n");
2778 ok(memids[0] == MEMBERID_NIL, "got invalid memid[0]: %x\n", memids[0]);
2779 ok(memids[1] == 0xdeadbeef, "got invalid memid[1]\n");
2780 if(tinfos[0])
2781 ITypeInfo_Release(tinfos[0]);
2783 hres = ITypeLib_GetDocumentation(tl, -1, &name, &docstring, &helpcontext, &helpfile);
2784 ok(hres == S_OK, "got %08x\n", hres);
2785 ok(memcmp(typelibW, name, sizeof(typelibW)) == 0, "got wrong typelib name: %s\n",
2786 wine_dbgstr_w(name));
2787 ok(docstring == NULL, "got wrong docstring: %s\n", wine_dbgstr_w(docstring));
2788 ok(helpcontext == 0, "got wrong helpcontext: 0x%x\n", helpcontext);
2789 ok(memcmp(helpfileW, helpfile, sizeof(helpfileW)) == 0,
2790 "got wrong helpfile: %s\n", wine_dbgstr_w(helpfile));
2791 SysFreeString(name);
2792 SysFreeString(helpfile);
2794 hres = ITypeLib_GetDocumentation(tl, 0, &name, &docstring, &helpcontext, &helpfile);
2795 ok(hres == S_OK, "got %08x\n", hres);
2796 ok(memcmp(interface1W, name, sizeof(interface1W)) == 0, "got wrong typeinfo name: %s\n",
2797 wine_dbgstr_w(name));
2798 ok(docstring == NULL, "got wrong docstring: %s\n", wine_dbgstr_w(docstring));
2799 ok(helpcontext == 0, "got wrong helpcontext: 0x%x\n", helpcontext);
2800 ok(memcmp(helpfileW, helpfile, sizeof(helpfileW)) == 0,
2801 "got wrong helpfile: %s\n", wine_dbgstr_w(helpfile));
2802 SysFreeString(name);
2803 SysFreeString(helpfile);
2805 hres = ITypeLib_GetTypeInfo(tl, 0, &ti);
2806 ok(hres == S_OK, "got %08x\n", hres);
2808 hres = ITypeInfo_GetTypeAttr(ti, &typeattr);
2809 ok(hres == S_OK, "got %08x\n", hres);
2810 ok(typeattr->cbSizeInstance == sizeof(void*), "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2811 ok(typeattr->typekind == TKIND_INTERFACE, "typekind = %d\n", typeattr->typekind);
2812 ok(typeattr->cFuncs == 13, "cFuncs = %d\n", typeattr->cFuncs);
2813 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2814 ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
2815 #ifdef _WIN64
2816 if(sys == SYS_WIN32)
2817 todo_wine ok(typeattr->cbSizeVft == 16 * sizeof(void*), "cbSizeVft = %d\n", typeattr->cbSizeVft);
2818 else
2819 #endif
2820 ok(typeattr->cbSizeVft == 16 * sizeof(void*), "cbSizeVft = %d\n", typeattr->cbSizeVft);
2821 ok(typeattr->cbAlignment == alignment, "cbAlignment = %d\n", typeattr->cbAlignment);
2822 ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
2823 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2824 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2825 ITypeInfo_ReleaseTypeAttr(ti, typeattr);
2827 hres = ITypeInfo_GetRefTypeOfImplType(ti, 0, &hreftype);
2828 ok(hres == S_OK, "got %08x\n", hres);
2829 ok(hreftype == 3, "hreftype = %d\n", hreftype);
2831 hres = ITypeInfo_GetRefTypeInfo(ti, hreftype, &unknown);
2832 ok(hres == S_OK, "got %08x\n", hres);
2834 hres = ITypeInfo_GetTypeAttr(unknown, &typeattr);
2835 ok(hres == S_OK, "got %08x\n", hres);
2836 ok(IsEqualGUID(&typeattr->guid, &IID_IUnknown), "got wrong reftypeinfo\n");
2837 ITypeInfo_ReleaseTypeAttr(unknown, typeattr);
2839 ITypeInfo_Release(unknown);
2841 hres = ITypeInfo_GetFuncDesc(ti, 0, &pfuncdesc);
2842 ok(hres == S_OK, "got %08x\n", hres);
2843 ok(pfuncdesc->memid == 0, "got %x\n", pfuncdesc->memid);
2844 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2845 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2846 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2847 ok(pfuncdesc->invkind == INVOKE_PROPERTYPUTREF, "got 0x%x\n", pfuncdesc->invkind);
2848 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2849 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2850 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2851 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2852 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2853 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2854 edesc = pfuncdesc->lprgelemdescParam;
2855 ok(edesc->tdesc.vt == VT_BSTR, "got: %d\n", edesc->tdesc.vt);
2856 ok(U(*edesc).idldesc.wIDLFlags == IDLFLAG_FIN, "got: %x\n", U(*edesc).idldesc.wIDLFlags);
2858 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
2859 ok(hres == S_OK, "got: %08x\n", hres);
2860 ok(!memcmp(name, func1W, sizeof(func1W)), "got name: %s\n", wine_dbgstr_w(name));
2861 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
2862 ok(helpcontext == 0x201, "got helpcontext: 0x%x\n", helpcontext);
2863 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
2864 SysFreeString(name);
2865 SysFreeString(helpfile);
2867 hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, NULL, 0, &cnames);
2868 ok(hres == E_INVALIDARG, "got: %08x\n", hres);
2870 cnames = 8;
2871 hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, 0, &cnames);
2872 ok(hres == S_OK, "got: %08x\n", hres);
2873 ok(cnames == 0, "got: %u\n", cnames);
2875 hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, sizeof(names) / sizeof(*names), &cnames);
2876 ok(hres == S_OK, "got: %08x\n", hres);
2877 ok(cnames == 1, "got: %u\n", cnames);
2878 ok(!memcmp(names[0], func1W, sizeof(func1W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
2879 SysFreeString(names[0]);
2881 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
2883 hres = ITypeInfo_GetFuncDesc(ti, 1, &pfuncdesc);
2884 ok(hres == S_OK, "got %08x\n", hres);
2885 ok(pfuncdesc->memid == 0x60010001, "got %x\n", pfuncdesc->memid);
2886 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2887 ok(pfuncdesc->lprgelemdescParam == NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2888 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2889 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2890 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2891 ok(pfuncdesc->cParams == 0, "got %d\n", pfuncdesc->cParams);
2892 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2893 #ifdef _WIN64
2894 if(sys == SYS_WIN32)
2895 todo_wine ok(pfuncdesc->oVft == 4 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
2896 else
2897 #endif
2898 ok(pfuncdesc->oVft == 4 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
2899 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2900 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2901 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2903 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
2904 ok(hres == S_OK, "got: %08x\n", hres);
2905 ok(name == NULL, "got name: %s\n", wine_dbgstr_w(name));
2906 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
2907 ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
2908 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
2909 SysFreeString(helpfile);
2910 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
2912 hres = ITypeInfo_GetFuncDesc(ti, 2, &pfuncdesc);
2913 ok(hres == S_OK, "got %08x\n", hres);
2914 ok(pfuncdesc->memid == 0x1, "got %x\n", pfuncdesc->memid);
2915 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2916 ok(pfuncdesc->lprgelemdescParam == NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2917 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2918 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2919 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2920 ok(pfuncdesc->cParams == 0, "got %d\n", pfuncdesc->cParams);
2921 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2922 #ifdef _WIN64
2923 if(sys == SYS_WIN32)
2924 todo_wine ok(pfuncdesc->oVft == 5 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
2925 else
2926 #endif
2927 ok(pfuncdesc->oVft == 5 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
2928 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2929 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2930 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2932 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
2933 ok(hres == S_OK, "got: %08x\n", hres);
2934 ok(name == NULL, "got name: %s\n", wine_dbgstr_w(name));
2935 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
2936 ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
2937 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
2938 SysFreeString(helpfile);
2939 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
2941 hres = ITypeInfo_GetFuncDesc(ti, 3, &pfuncdesc);
2942 ok(hres == S_OK, "got %08x\n", hres);
2943 ok(pfuncdesc->memid == 0x6001000b, "got %x\n", pfuncdesc->memid);
2944 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2945 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2946 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2947 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2948 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2949 ok(pfuncdesc->cParams == 2, "got %d\n", pfuncdesc->cParams);
2950 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2951 #ifdef _WIN64
2952 if(sys == SYS_WIN32)
2953 todo_wine ok(pfuncdesc->oVft == 6 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
2954 else
2955 #endif
2956 ok(pfuncdesc->oVft == 6 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
2957 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2958 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2959 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2961 edesc = pfuncdesc->lprgelemdescParam;
2962 ok(edesc->tdesc.vt == VT_BSTR, "got: %d\n", edesc->tdesc.vt);
2963 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2964 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2965 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
2966 U(*edesc).paramdesc.pparamdescex->cBytes);
2967 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_BSTR, "got: %d\n",
2968 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2969 ok(!lstrcmpW(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue), defaultQW),
2970 "got: %s\n",
2971 wine_dbgstr_w(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue)));
2973 edesc = pfuncdesc->lprgelemdescParam + 1;
2974 ok(edesc->tdesc.vt == VT_BSTR, "got: %d\n", edesc->tdesc.vt);
2975 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2976 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2977 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
2978 U(*edesc).paramdesc.pparamdescex->cBytes);
2979 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_BSTR, "got: %d\n",
2980 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2981 ok(!lstrcmpW(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue), defaultQW),
2982 "got: %s\n",
2983 wine_dbgstr_w(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue)));
2985 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
2986 ok(hres == S_OK, "got: %08x\n", hres);
2987 ok(!memcmp(name, func2W, sizeof(func2W)), "got name: %s\n", wine_dbgstr_w(name));
2988 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
2989 ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
2990 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
2991 SysFreeString(name);
2992 SysFreeString(helpfile);
2994 hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, sizeof(names) / sizeof(*names), &cnames);
2995 ok(hres == S_OK, "got: %08x\n", hres);
2996 ok(cnames == 3, "got: %u\n", cnames);
2997 ok(!memcmp(names[0], func2W, sizeof(func2W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
2998 ok(!memcmp(names[1], param1W, sizeof(func2W)), "got names[1]: %s\n", wine_dbgstr_w(names[1]));
2999 ok(!memcmp(names[2], param2W, sizeof(func2W)), "got names[2]: %s\n", wine_dbgstr_w(names[2]));
3000 SysFreeString(names[0]);
3001 SysFreeString(names[1]);
3002 SysFreeString(names[2]);
3003 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3005 hres = ITypeInfo_GetFuncDesc(ti, 4, &pfuncdesc);
3006 ok(hres == S_OK, "got %08x\n", hres);
3007 ok(pfuncdesc->memid == 0x6001000c, "got %x\n", pfuncdesc->memid);
3008 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3009 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3010 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3011 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3012 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3013 ok(pfuncdesc->cParams == 2, "got %d\n", pfuncdesc->cParams);
3014 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3015 #ifdef _WIN64
3016 if(sys == SYS_WIN32)
3017 todo_wine ok(pfuncdesc->oVft == 7 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3018 else
3019 #endif
3020 ok(pfuncdesc->oVft == 7 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3021 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3022 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3023 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3025 edesc = pfuncdesc->lprgelemdescParam;
3026 ok(edesc->tdesc.vt == VT_INT, "got: %d\n", edesc->tdesc.vt);
3027 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3028 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3029 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
3030 U(*edesc).paramdesc.pparamdescex->cBytes);
3031 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_I4, "got: %d\n",
3032 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3033 ok(V_I4(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0xFFFFFFFF,
3034 "got: 0x%x\n", V_I4(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3036 edesc = pfuncdesc->lprgelemdescParam + 1;
3037 ok(edesc->tdesc.vt == VT_INT, "got: %d\n", edesc->tdesc.vt);
3038 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3039 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3040 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
3041 U(*edesc).paramdesc.pparamdescex->cBytes);
3042 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_I4, "got: %d\n",
3043 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3044 ok(V_I4(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0xFFFFFFFF,
3045 "got: 0x%x\n", V_I4(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3047 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3048 ok(hres == S_OK, "got: %08x\n", hres);
3049 ok(name == NULL, "got name: %s\n", wine_dbgstr_w(name));
3050 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3051 ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
3052 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3053 SysFreeString(helpfile);
3054 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3056 hres = ITypeInfo_GetFuncDesc(ti, 5, &pfuncdesc);
3057 ok(hres == S_OK, "got %08x\n", hres);
3058 ok(pfuncdesc->memid == 0x60010005, "got %x\n", pfuncdesc->memid);
3059 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3060 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3061 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3062 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3063 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3064 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
3065 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3066 #ifdef _WIN64
3067 if(sys == SYS_WIN32)
3068 todo_wine ok(pfuncdesc->oVft == 8 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3069 else
3070 #endif
3071 ok(pfuncdesc->oVft == 8 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3072 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3073 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3074 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3076 edesc = pfuncdesc->lprgelemdescParam;
3077 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3078 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
3079 U(*edesc).paramdesc.pparamdescex->cBytes);
3080 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_INT, "got: %d\n",
3081 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3082 ok(V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0x789, "got: 0x%x\n",
3083 V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3084 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT,
3085 "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3086 ok(edesc->tdesc.vt == VT_USERDEFINED, "got: %d\n", edesc->tdesc.vt);
3087 ok(U(edesc->tdesc).hreftype == hreftype, "got: 0x%x\n", U(edesc->tdesc).hreftype);
3089 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3090 ok(hres == S_OK, "got: %08x\n", hres);
3091 ok(name == NULL, "got name: %s\n", wine_dbgstr_w(name));
3092 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3093 ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
3094 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3095 SysFreeString(helpfile);
3096 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3098 hres = ITypeInfo_GetFuncDesc(ti, 6, &pfuncdesc);
3099 ok(hres == S_OK, "got %08x\n", hres);
3100 ok(pfuncdesc->memid == 0x60010006, "got %x\n", pfuncdesc->memid);
3101 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3102 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3103 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3104 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3105 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3106 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
3107 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3108 #ifdef _WIN64
3109 if(sys == SYS_WIN32)
3110 todo_wine ok(pfuncdesc->oVft == 9 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3111 else
3112 #endif
3113 ok(pfuncdesc->oVft == 9 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3114 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3115 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VARIANT, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3116 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3118 edesc = pfuncdesc->lprgelemdescParam;
3119 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3120 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
3121 U(*edesc).paramdesc.pparamdescex->cBytes);
3122 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_INT, "got: %d\n",
3123 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3124 ok(V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0x3, "got: 0x%x\n",
3125 V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3126 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT,
3127 "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3128 ok(edesc->tdesc.vt == VT_VARIANT, "got: %d\n", edesc->tdesc.vt);
3129 ok(U(edesc->tdesc).hreftype == 0, "got: 0x%x\n", U(edesc->tdesc).hreftype);
3131 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3132 ok(hres == S_OK, "got: %08x\n", hres);
3133 ok(name == NULL, "got name: %s\n", wine_dbgstr_w(name));
3134 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3135 ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
3136 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3137 SysFreeString(helpfile);
3138 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3140 hres = ITypeInfo_GetFuncDesc(ti, 7, &pfuncdesc);
3141 ok(hres == S_OK, "got %08x\n", hres);
3142 ok(pfuncdesc->memid == 0x60010009, "got %x\n", pfuncdesc->memid);
3143 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3144 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3145 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3146 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3147 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3148 ok(pfuncdesc->cParams == 2, "got %d\n", pfuncdesc->cParams);
3149 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3150 #ifdef _WIN64
3151 if(sys == SYS_WIN32)
3152 todo_wine ok(pfuncdesc->oVft == 10 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3153 else
3154 #endif
3155 ok(pfuncdesc->oVft == 10 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3156 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3157 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3158 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3160 edesc = pfuncdesc->lprgelemdescParam;
3161 ok(edesc->tdesc.vt == VT_INT, "got: %d\n", edesc->tdesc.vt);
3162 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FIN, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3163 ok(U(*edesc).paramdesc.pparamdescex == NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3165 edesc = pfuncdesc->lprgelemdescParam + 1;
3166 ok(edesc->tdesc.vt == VT_UI2, "got: %d\n", edesc->tdesc.vt);
3167 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3168 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3169 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
3170 U(*edesc).paramdesc.pparamdescex->cBytes);
3171 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_UI2, "got: %d\n",
3172 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3173 ok(V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0xFFFF, "got: 0x%x\n",
3174 V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3176 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3177 ok(hres == S_OK, "got: %08x\n", hres);
3178 ok(name == NULL, "got name: %s\n", wine_dbgstr_w(name));
3179 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3180 ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
3181 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3182 SysFreeString(helpfile);
3183 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3185 hres = ITypeInfo_GetFuncDesc(ti, 8, &pfuncdesc);
3186 ok(hres == S_OK, "got %08x\n", hres);
3187 ok(pfuncdesc->memid == 0x60010003, "got %x\n", pfuncdesc->memid);
3188 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3189 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3190 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3191 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3192 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3193 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
3194 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3195 #ifdef _WIN64
3196 if(sys == SYS_WIN32)
3197 todo_wine ok(pfuncdesc->oVft == 11 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3198 else
3199 #endif
3200 ok(pfuncdesc->oVft == 11 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3201 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3202 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3203 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3205 edesc = pfuncdesc->lprgelemdescParam;
3206 ok(edesc->tdesc.vt == VT_INT, "got: %d\n", edesc->tdesc.vt);
3207 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3208 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3209 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
3210 U(*edesc).paramdesc.pparamdescex->cBytes);
3211 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_I4, "got: %d\n",
3212 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3213 ok(V_I4(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0x123, "got: 0x%x\n",
3214 V_I4(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3216 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3217 ok(hres == S_OK, "got: %08x\n", hres);
3218 ok(name == NULL, "got name: %s\n", wine_dbgstr_w(name));
3219 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3220 ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
3221 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3222 SysFreeString(helpfile);
3223 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3225 hres = ITypeInfo_GetFuncDesc(ti, 9, &pfuncdesc);
3226 ok(hres == S_OK, "got %08x\n", hres);
3227 ok(pfuncdesc->memid == 0, "got %x\n", pfuncdesc->memid);
3228 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3229 ok(pfuncdesc->lprgelemdescParam == NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3230 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3231 ok(pfuncdesc->invkind == INVOKE_PROPERTYGET, "got 0x%x\n", pfuncdesc->invkind);
3232 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3233 ok(pfuncdesc->cParams == 0, "got %d\n", pfuncdesc->cParams);
3234 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3235 #ifdef _WIN64
3236 if(sys == SYS_WIN32)
3237 todo_wine ok(pfuncdesc->oVft == 12 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3238 else
3239 #endif
3240 ok(pfuncdesc->oVft == 12 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3241 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3242 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_BSTR, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3243 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3245 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3246 ok(hres == S_OK, "got: %08x\n", hres);
3247 ok(!memcmp(name, func1W, sizeof(func1W)), "got name: %s\n", wine_dbgstr_w(name));
3248 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3249 ok(helpcontext == 0x201, "got helpcontext: 0x%x\n", helpcontext);
3250 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3251 SysFreeString(name);
3252 SysFreeString(helpfile);
3254 hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, sizeof(names) / sizeof(*names), &cnames);
3255 ok(hres == S_OK, "got: %08x\n", hres);
3256 ok(cnames == 1, "got: %u\n", cnames);
3257 ok(!memcmp(names[0], func1W, sizeof(func1W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
3258 SysFreeString(names[0]);
3259 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3261 hres = ITypeInfo_GetFuncDesc(ti, 10, &pfuncdesc);
3262 ok(hres == S_OK, "got %08x\n", hres);
3263 ok(pfuncdesc->memid == 0x60010007, "got %x\n", pfuncdesc->memid);
3264 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3265 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3266 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3267 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3268 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3269 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
3270 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3271 #ifdef _WIN64
3272 if(sys == SYS_WIN32)
3273 todo_wine ok(pfuncdesc->oVft == 13 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3274 else
3275 #endif
3276 ok(pfuncdesc->oVft == 13 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3277 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3278 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3279 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3281 edesc = pfuncdesc->lprgelemdescParam;
3282 ok(edesc->tdesc.vt == VT_PTR, "got: %d\n", edesc->tdesc.vt);
3283 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FIN, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3284 ok(U(*edesc).paramdesc.pparamdescex == NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3285 ok(U(edesc->tdesc).lptdesc != NULL, "got: %p\n", U(edesc->tdesc).lptdesc);
3286 ok(U(edesc->tdesc).lptdesc->vt == VT_PTR, "got: %d\n", U(edesc->tdesc).lptdesc->vt);
3287 ok(U(*U(edesc->tdesc).lptdesc).lptdesc != NULL, "got: %p\n", U(*U(edesc->tdesc).lptdesc).lptdesc);
3288 ok(U(*U(edesc->tdesc).lptdesc).lptdesc->vt == VT_BSTR, "got: %d\n", U(*U(edesc->tdesc).lptdesc).lptdesc->vt);
3290 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3291 ok(hres == S_OK, "got: %08x\n", hres);
3292 ok(name == NULL, "got name: %s\n", wine_dbgstr_w(name));
3293 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3294 ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
3295 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3296 SysFreeString(helpfile);
3297 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3299 hres = ITypeInfo_GetFuncDesc(ti, 11, &pfuncdesc);
3300 ok(hres == S_OK, "got %08x\n", hres);
3301 ok(pfuncdesc->memid == 0x60010004, "got %x\n", pfuncdesc->memid);
3302 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3303 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3304 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3305 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3306 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3307 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
3308 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3309 #ifdef _WIN64
3310 if(sys == SYS_WIN32)
3311 todo_wine ok(pfuncdesc->oVft == 14 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3312 else
3313 #endif
3314 ok(pfuncdesc->oVft == 14 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3315 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3316 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3317 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3319 edesc = pfuncdesc->lprgelemdescParam;
3320 ok(edesc->tdesc.vt == VT_PTR, "got: %d\n", edesc->tdesc.vt);
3321 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FIN, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3322 ok(U(*edesc).paramdesc.pparamdescex == NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3323 ok(U(edesc->tdesc).lptdesc != NULL, "got: %p\n", U(edesc->tdesc).lptdesc);
3324 ok(U(edesc->tdesc).lptdesc->vt == VT_BSTR, "got: %d\n", U(edesc->tdesc).lptdesc->vt);
3326 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3327 ok(hres == S_OK, "got: %08x\n", hres);
3328 ok(name == NULL, "got name: %s\n", wine_dbgstr_w(name));
3329 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3330 ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
3331 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3332 SysFreeString(helpfile);
3333 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3335 hres = ITypeInfo_GetFuncDesc(ti, 12, &pfuncdesc);
3336 ok(hres == S_OK, "got %08x\n", hres);
3337 ok(pfuncdesc->memid == 0, "got %x\n", pfuncdesc->memid);
3338 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3339 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3340 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3341 ok(pfuncdesc->invkind == INVOKE_PROPERTYPUT, "got 0x%x\n", pfuncdesc->invkind);
3342 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3343 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
3344 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3345 #ifdef _WIN64
3346 if(sys == SYS_WIN32)
3347 todo_wine ok(pfuncdesc->oVft == 15 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3348 else
3349 #endif
3350 ok(pfuncdesc->oVft == 15 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3351 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3352 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3353 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3355 edesc = pfuncdesc->lprgelemdescParam;
3356 ok(edesc->tdesc.vt == VT_BSTR, "got: %d\n", edesc->tdesc.vt);
3357 ok(U(*edesc).idldesc.wIDLFlags == IDLFLAG_FIN, "got: %x\n", U(*edesc).idldesc.wIDLFlags);
3359 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3360 ok(hres == S_OK, "got: %08x\n", hres);
3361 ok(!memcmp(name, func1W, sizeof(func1W)), "got name: %s\n", wine_dbgstr_w(name));
3362 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3363 ok(helpcontext == 0x201, "got helpcontext: 0x%x\n", helpcontext);
3364 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3365 SysFreeString(name);
3366 SysFreeString(helpfile);
3368 hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, sizeof(names) / sizeof(*names), &cnames);
3369 ok(hres == S_OK, "got: %08x\n", hres);
3370 ok(cnames == 1, "got: %u\n", cnames);
3371 ok(!memcmp(names[0], func1W, sizeof(func1W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
3372 SysFreeString(names[0]);
3373 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3375 hres = ITypeInfo_GetFuncDesc(ti, 13, &pfuncdesc);
3376 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
3378 ok(ITypeInfo_Release(ti) == 0, "Object should be freed\n");
3380 hres = ITypeLib_GetTypeInfo(tl, 1, &ti);
3381 ok(hres == S_OK, "got %08x\n", hres);
3383 hres = ITypeInfo_GetTypeAttr(ti, &typeattr);
3384 ok(hres == S_OK, "got %08x\n", hres);
3385 ok(typeattr->cbSizeInstance == sizeof(void*), "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
3386 ok(typeattr->typekind == TKIND_INTERFACE, "typekind = %d\n", typeattr->typekind);
3387 ok(typeattr->cFuncs == 2, "cFuncs = %d\n", typeattr->cFuncs);
3388 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
3389 ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
3390 ok(typeattr->cbSizeVft == 0xaab8 || typeattr->cbSizeVft == 0xaab0 ||
3391 typeattr->cbSizeVft == 0x5560, "cbSizeVft = 0x%x\n", typeattr->cbSizeVft);
3392 ok(typeattr->cbAlignment == alignment, "cbAlignment = %d\n", typeattr->cbAlignment);
3393 ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
3394 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
3395 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
3396 ITypeInfo_ReleaseTypeAttr(ti, typeattr);
3398 hres = ITypeInfo_GetRefTypeOfImplType(ti, 0, &hreftype);
3399 ok(hres == S_OK, "got %08x\n", hres);
3401 hres = ITypeInfo_GetFuncDesc(ti, 0, &pfuncdesc);
3402 ok(hres == S_OK, "got %08x\n", hres);
3403 ok(pfuncdesc->memid == 0x60020000, "got %x\n", pfuncdesc->memid);
3404 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3405 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3406 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3407 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3408 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3409 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
3410 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3411 ok(pfuncdesc->oVft == 0xffffaaa8 ||
3412 pfuncdesc->oVft == 0x5550, "got %x\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);
3417 edesc = pfuncdesc->lprgelemdescParam;
3418 ok(edesc->tdesc.vt == VT_VARIANT, "got: %d\n", edesc->tdesc.vt);
3419 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT,
3420 "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3421 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3422 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
3423 U(*edesc).paramdesc.pparamdescex->cBytes);
3424 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_INT, "got: %d\n",
3425 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3426 ok(V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0x3, "got: 0x%x\n",
3427 V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3428 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT,
3429 "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3430 ok(U(edesc->tdesc).lptdesc == NULL, "got: %p\n", U(edesc->tdesc).lptdesc);
3431 ok(U(edesc->tdesc).hreftype == 0, "got: %d\n", U(edesc->tdesc).hreftype);
3432 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3434 hres = ITypeInfo_GetFuncDesc(ti, 1, &pfuncdesc);
3435 ok(hres == S_OK, "got %08x\n", hres);
3436 ok(pfuncdesc->memid == 0x60020001, "got %x\n", pfuncdesc->memid);
3437 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3438 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3439 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3440 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3441 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3442 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
3443 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3444 ok(pfuncdesc->oVft == 0xffffaaac ||
3445 pfuncdesc->oVft == 0xffffaab0 ||
3446 pfuncdesc->oVft == 0x5558, "got %x\n", pfuncdesc->oVft);
3447 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3448 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3449 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3451 edesc = pfuncdesc->lprgelemdescParam;
3452 ok(edesc->tdesc.vt == VT_VARIANT, "got: %d\n", edesc->tdesc.vt);
3453 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT,
3454 "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3455 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3456 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
3457 U(*edesc).paramdesc.pparamdescex->cBytes);
3458 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_INT, "got: %d\n",
3459 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3460 ok(V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0x3, "got: 0x%x\n",
3461 V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3462 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT,
3463 "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3464 ok(U(edesc->tdesc).lptdesc == NULL, "got: %p\n", U(edesc->tdesc).lptdesc);
3465 ok(U(edesc->tdesc).hreftype == 0, "got: %d\n", U(edesc->tdesc).hreftype);
3466 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3468 ok(ITypeInfo_Release(ti) == 0, "Object should be freed\n");
3470 hres = ITypeLib_GetTypeInfo(tl, 2, &ti);
3471 ok(hres == S_OK, "got %08x\n", hres);
3473 hres = ITypeInfo_QueryInterface(ti, &IID_ITypeInfo2, (void**)&ti2);
3474 ok(hres == S_OK, "got %08x\n", hres);
3476 hres = ITypeInfo_GetTypeAttr(ti, &typeattr);
3477 ok(hres == S_OK, "got %08x\n", hres);
3478 ok(typeattr->cbSizeInstance == sizeof(void*), "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
3479 ok(typeattr->typekind == TKIND_INTERFACE, "typekind = %d\n", typeattr->typekind);
3480 ok(typeattr->cFuncs == 0, "cFuncs = %d\n", typeattr->cFuncs);
3481 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
3482 ok(typeattr->cImplTypes == 0, "cImplTypes = %d\n", typeattr->cImplTypes);
3483 ok(typeattr->cbSizeVft == 0, "cbSizeVft = %d\n", typeattr->cbSizeVft);
3484 ok(typeattr->cbAlignment == alignment, "cbAlignment = %d\n", typeattr->cbAlignment);
3485 ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
3486 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
3487 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
3488 ITypeInfo_ReleaseTypeAttr(ti, typeattr);
3490 VariantClear(&cust_data);
3491 hres = ITypeInfo2_GetCustData(ti2, &custguid, &cust_data);
3492 ok(hres == S_OK, "got %08x\n", hres);
3493 ok(V_VT(&cust_data) == VT_BSTR, "got wrong custdata type: %u\n", V_VT(&cust_data));
3494 ok(!lstrcmpW(V_BSTR(&cust_data), asdfW), "got wrong custdata value: %s\n", wine_dbgstr_w(V_BSTR(&cust_data)));
3495 SysFreeString(V_BSTR(&cust_data));
3497 ITypeInfo2_Release(ti2);
3498 ok(ITypeInfo_Release(ti) == 0, "Object should be freed\n");
3500 hres = ITypeLib_GetTypeInfo(tl, 3, &ti);
3501 ok(hres == S_OK, "got %08x\n", hres);
3503 hres = ITypeInfo_GetTypeAttr(ti, &typeattr);
3504 ok(hres == S_OK, "got %08x\n", hres);
3505 ok(typeattr->cbSizeInstance == sizeof(void*), "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
3506 ok(typeattr->typekind == TKIND_COCLASS, "typekind = %d\n", typeattr->typekind);
3507 ok(typeattr->cFuncs == 0, "cFuncs = %d\n", typeattr->cFuncs);
3508 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
3509 ok(typeattr->cImplTypes == 3, "cImplTypes = %d\n", typeattr->cImplTypes);
3510 ok(typeattr->cbSizeVft == 0, "cbSizeVft = %d\n", typeattr->cbSizeVft);
3511 ok(typeattr->cbAlignment == alignment, "cbAlignment = %d\n", typeattr->cbAlignment);
3512 ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
3513 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
3514 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
3515 ITypeInfo_ReleaseTypeAttr(ti, typeattr);
3517 hres = ITypeInfo_GetRefTypeOfImplType(ti, 0, &hreftype);
3518 ok(hres == S_OK, "got %08x\n", hres);
3519 ok(hreftype == 0, "got wrong hreftype: %x\n", hreftype);
3521 hres = ITypeInfo_GetImplTypeFlags(ti, 0, &impltypeflags);
3522 ok(hres == S_OK, "got %08x\n", hres);
3523 ok(impltypeflags == IMPLTYPEFLAG_FDEFAULT, "got wrong flag: %x\n", impltypeflags);
3525 hres = ITypeInfo_GetRefTypeOfImplType(ti, 1, &hreftype);
3526 ok(hres == S_OK, "got %08x\n", hres);
3527 ok(hreftype == 1, "got wrong hreftype: %x\n", hreftype);
3529 hres = ITypeInfo_GetImplTypeFlags(ti, 1, &impltypeflags);
3530 ok(hres == S_OK, "got %08x\n", hres);
3531 ok(impltypeflags == IMPLTYPEFLAG_FRESTRICTED, "got wrong flag: %x\n", impltypeflags);
3533 hres = ITypeInfo_GetRefTypeOfImplType(ti, 2, &hreftype);
3534 ok(hres == S_OK, "got %08x\n", hres);
3535 ok(hreftype == 1, "got wrong hreftype: %x\n", hreftype);
3537 hres = ITypeInfo_GetImplTypeFlags(ti, 2, &impltypeflags);
3538 ok(hres == S_OK, "got %08x\n", hres);
3539 ok(impltypeflags == 0, "got wrong flag: %x\n", impltypeflags);
3541 hres = ITypeInfo_GetRefTypeOfImplType(ti, 3, &hreftype);
3542 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
3544 ok(ITypeInfo_Release(ti) == 0, "Object should be freed\n");
3546 hres = ITypeLib_GetTypeInfo(tl, 4, &ti);
3547 ok(hres == S_OK, "got %08x\n", hres);
3549 hres = ITypeInfo_GetTypeAttr(ti, &typeattr);
3550 ok(hres == S_OK, "got %08x\n", hres);
3551 ok(typeattr->cbSizeInstance == sizeof(void*), "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
3552 ok(typeattr->typekind == TKIND_DISPATCH, "typekind = %d\n", typeattr->typekind);
3553 ok(typeattr->cFuncs == 8, "cFuncs = %d\n", typeattr->cFuncs);
3554 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
3555 ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
3556 ok(typeattr->cbSizeVft == 7 * sizeof(void*), "cbSizeVft = %d\n", typeattr->cbSizeVft);
3557 ok(typeattr->cbAlignment == alignment, "cbAlignment = %d\n", typeattr->cbAlignment);
3558 ok(typeattr->wTypeFlags == (TYPEFLAG_FDISPATCHABLE | TYPEFLAG_FDUAL), "wTypeFlags = 0x%x\n", typeattr->wTypeFlags);
3559 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
3560 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
3561 ITypeInfo_ReleaseTypeAttr(ti, typeattr);
3563 hres = ITypeInfo_GetTypeComp(ti, &tcomp);
3564 ok(hres == S_OK, "got %08x\n", hres);
3566 hres = ITypeComp_Bind(tcomp, invokeW, 0, INVOKE_FUNC, &interface1, &desckind, &bindptr);
3567 ok(hres == S_OK, "got %08x\n", hres);
3568 ok(desckind == DESCKIND_FUNCDESC, "got wrong desckind: 0x%x\n", desckind);
3569 ok(bindptr.lpfuncdesc->memid == 0x60010003, "got %x\n", bindptr.lpfuncdesc->memid);
3570 ok(bindptr.lpfuncdesc->lprgscode == NULL, "got %p\n", bindptr.lpfuncdesc->lprgscode);
3571 ok(bindptr.lpfuncdesc->lprgelemdescParam != NULL, "got %p\n", bindptr.lpfuncdesc->lprgelemdescParam);
3572 ok(bindptr.lpfuncdesc->funckind == FUNC_DISPATCH, "got 0x%x\n", bindptr.lpfuncdesc->funckind);
3573 ok(bindptr.lpfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", bindptr.lpfuncdesc->invkind);
3574 ok(bindptr.lpfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", bindptr.lpfuncdesc->callconv);
3575 ok(bindptr.lpfuncdesc->cParams == 8, "got %d\n", bindptr.lpfuncdesc->cParams);
3576 ok(bindptr.lpfuncdesc->cParamsOpt == 0, "got %d\n", bindptr.lpfuncdesc->cParamsOpt);
3577 #ifdef _WIN64
3578 if(sys == SYS_WIN32)
3579 todo_wine ok(bindptr.lpfuncdesc->oVft == 6 * sizeof(void*), "got %x\n", bindptr.lpfuncdesc->oVft);
3580 else
3581 #endif
3582 ok(bindptr.lpfuncdesc->oVft == 6 * sizeof(void*), "got %x\n", bindptr.lpfuncdesc->oVft);
3583 ok(bindptr.lpfuncdesc->cScodes == 0, "got %d\n", bindptr.lpfuncdesc->cScodes);
3584 ok(bindptr.lpfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", bindptr.lpfuncdesc->elemdescFunc.tdesc.vt);
3585 ok(bindptr.lpfuncdesc->wFuncFlags == FUNCFLAG_FRESTRICTED, "got 0x%x\n", bindptr.lpfuncdesc->wFuncFlags);
3587 ITypeInfo_ReleaseFuncDesc(interface1, bindptr.lpfuncdesc);
3588 ITypeInfo_Release(interface1);
3589 ITypeComp_Release(tcomp);
3591 hres = ITypeInfo_GetRefTypeOfImplType(ti, -1, &hreftype);
3592 ok(hres == S_OK, "got %08x\n", hres);
3593 ok(hreftype == -2, "got wrong hreftype: %x\n", hreftype);
3595 hres = ITypeInfo_GetRefTypeInfo(ti, hreftype, &interface1);
3596 ok(hres == S_OK, "got %08x\n", hres);
3598 hres = ITypeInfo_GetTypeAttr(interface1, &typeattr);
3599 ok(hres == S_OK, "got %08x\n", hres);
3600 ok(typeattr->cbSizeInstance == sizeof(void*), "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
3601 ok(typeattr->typekind == TKIND_INTERFACE, "typekind = %d\n", typeattr->typekind);
3602 ok(typeattr->cFuncs == 1, "cFuncs = %d\n", typeattr->cFuncs);
3603 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
3604 ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
3605 #ifdef _WIN64
3606 if(sys == SYS_WIN32)
3607 todo_wine ok(typeattr->cbSizeVft == 8 * sizeof(void*), "cbSizeVft = %d\n", typeattr->cbSizeVft);
3608 else
3609 #endif
3610 ok(typeattr->cbSizeVft == 8 * sizeof(void*), "cbSizeVft = %d\n", typeattr->cbSizeVft);
3611 ok(typeattr->cbAlignment == alignment, "cbAlignment = %d\n", typeattr->cbAlignment);
3612 ok(typeattr->wTypeFlags == (TYPEFLAG_FDISPATCHABLE | TYPEFLAG_FDUAL), "wTypeFlags = 0x%x\n", typeattr->wTypeFlags);
3613 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
3614 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
3615 ITypeInfo_ReleaseTypeAttr(interface1, typeattr);
3617 ITypeInfo_Release(interface1);
3619 ok(ITypeInfo_Release(ti) == 0, "Object should be freed\n");
3621 hres = ITypeLib_GetTypeInfo(tl, 5, &ti);
3622 ok(hres == S_OK, "got %08x\n", hres);
3624 hres = ITypeInfo_GetTypeAttr(ti, &typeattr);
3625 ok(hres == S_OK, "got %08x\n", hres);
3626 ok(typeattr->cbSizeInstance == 8, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
3627 ok(typeattr->typekind == TKIND_ALIAS, "typekind = %d\n", typeattr->typekind);
3628 ok(typeattr->cFuncs == 0, "cFuncs = %d\n", typeattr->cFuncs);
3629 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
3630 ok(typeattr->cImplTypes == 0, "cImplTypes = %d\n", typeattr->cImplTypes);
3631 ok(typeattr->cbSizeVft == 0, "cbSizeVft = %d\n", typeattr->cbSizeVft);
3632 ok(typeattr->cbAlignment == alignment, "cbAlignment = %d\n", typeattr->cbAlignment);
3633 ok(typeattr->wTypeFlags == 0, "wTypeFlags = 0x%x\n", typeattr->wTypeFlags);
3634 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
3635 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
3636 ok(typeattr->tdescAlias.vt == VT_R8, "Got wrong tdescAlias.vt: %u\n", typeattr->tdescAlias.vt);
3637 ITypeInfo_ReleaseTypeAttr(ti, typeattr);
3639 ok(ITypeInfo_Release(ti) == 0, "Object should be freed\n");
3641 ok(ITypeLib_Release(tl)==0, "Object should be freed\n");
3643 DeleteFileA(filename);
3646 #if 0 /* use this to generate more tests */
3648 #define OLE_CHECK(x) { HRESULT hr = x; if (FAILED(hr)) { printf(#x "failed - %x\n", hr); return; } }
3650 static char *dump_string(LPWSTR wstr)
3652 int size = lstrlenW(wstr)+3;
3653 char *out = CoTaskMemAlloc(size);
3654 WideCharToMultiByte(20127, 0, wstr, -1, out+1, size, NULL, NULL);
3655 out[0] = '\"';
3656 strcat(out, "\"");
3657 return out;
3660 struct map_entry
3662 DWORD value;
3663 const char *name;
3666 #define MAP_ENTRY(x) { x, #x }
3667 static const struct map_entry tkind_map[] = {
3668 MAP_ENTRY(TKIND_ENUM),
3669 MAP_ENTRY(TKIND_RECORD),
3670 MAP_ENTRY(TKIND_MODULE),
3671 MAP_ENTRY(TKIND_INTERFACE),
3672 MAP_ENTRY(TKIND_DISPATCH),
3673 MAP_ENTRY(TKIND_COCLASS),
3674 MAP_ENTRY(TKIND_ALIAS),
3675 MAP_ENTRY(TKIND_UNION),
3676 MAP_ENTRY(TKIND_MAX),
3677 {0, NULL}
3680 static const struct map_entry funckind_map[] = {
3681 MAP_ENTRY(FUNC_VIRTUAL),
3682 MAP_ENTRY(FUNC_PUREVIRTUAL),
3683 MAP_ENTRY(FUNC_NONVIRTUAL),
3684 MAP_ENTRY(FUNC_STATIC),
3685 MAP_ENTRY(FUNC_DISPATCH),
3686 {0, NULL}
3689 static const struct map_entry invkind_map[] = {
3690 MAP_ENTRY(INVOKE_FUNC),
3691 MAP_ENTRY(INVOKE_PROPERTYGET),
3692 MAP_ENTRY(INVOKE_PROPERTYPUT),
3693 MAP_ENTRY(INVOKE_PROPERTYPUTREF),
3694 {0, NULL}
3697 #undef MAP_ENTRY
3699 static const char *map_value(DWORD val, const struct map_entry *map)
3701 static int map_id;
3702 static char bufs[16][256];
3703 char *buf;
3705 while (map->name)
3707 if (map->value == val)
3708 return map->name;
3709 map++;
3712 buf = bufs[(map_id++)%16];
3713 sprintf(buf, "0x%x", val);
3714 return buf;
3717 static void test_dump_typelib(const char *name)
3719 WCHAR wszString[260];
3720 ITypeInfo *info;
3721 ITypeLib *lib;
3722 int count;
3723 int i;
3725 MultiByteToWideChar(CP_ACP, 0, name, -1, wszString, 260);
3726 OLE_CHECK(LoadTypeLib(wszString, &lib));
3727 count = ITypeLib_GetTypeInfoCount(lib);
3728 printf("/* interfaces count: %d */\n", count);
3729 for (i = 0; i < count; i++)
3731 TYPEATTR *attr;
3732 BSTR name;
3733 int f = 0;
3735 OLE_CHECK(ITypeLib_GetDocumentation(lib, i, &name, NULL, NULL, NULL));
3736 printf("{\n"
3737 " %s,\n", dump_string(name));
3738 SysFreeString(name);
3740 OLE_CHECK(ITypeLib_GetTypeInfo(lib, i, &info));
3741 ITypeInfo_GetTypeAttr(info, &attr);
3742 printf(" /*kind*/ %s, /*flags*/ 0x%x, /*align*/ %d, /*size*/ %d,\n"
3743 " /*#vtbl*/ %d, /*#func*/ %d,\n"
3744 " {\n",
3745 map_value(attr->typekind, tkind_map), attr->wTypeFlags, attr->cbAlignment, attr->cbSizeInstance, attr->cbSizeVft,
3746 attr->cFuncs);
3747 ITypeInfo_ReleaseTypeAttr(info, attr);
3748 while (1)
3750 FUNCDESC *desc;
3751 BSTR tab[256];
3752 UINT cNames;
3753 int p;
3755 if (FAILED(ITypeInfo_GetFuncDesc(info, f, &desc)))
3756 break;
3757 printf(" {\n"
3758 " 0x%x, /*func*/ %s, /*inv*/ %s, /*call*/ 0x%x,\n",
3759 desc->memid, map_value(desc->funckind, funckind_map), map_value(desc->invkind, invkind_map),
3760 desc->callconv);
3761 printf(" /*#param*/ %d, /*#opt*/ %d, /*vtbl*/ %d, /*#scodes*/ %d, /*flags*/ 0x%x,\n",
3762 desc->cParams, desc->cParamsOpt, desc->oVft, desc->cScodes, desc->wFuncFlags);
3763 printf(" {%d, %x}, /* ret */\n", desc->elemdescFunc.tdesc.vt, desc->elemdescFunc.paramdesc.wParamFlags);
3764 printf(" { /* params */\n");
3765 for (p = 0; p < desc->cParams; p++)
3767 ELEMDESC e = desc->lprgelemdescParam[p];
3768 printf(" {%d, %x},\n", e.tdesc.vt, e.paramdesc.wParamFlags);
3770 printf(" {-1, -1}\n");
3771 printf(" },\n");
3772 printf(" { /* names */\n");
3773 OLE_CHECK(ITypeInfo_GetNames(info, desc->memid, tab, 256, &cNames));
3774 for (p = 0; p < cNames; p++)
3776 printf(" %s,\n", dump_string(tab[p]));
3777 SysFreeString(tab[p]);
3779 printf(" NULL,\n");
3780 printf(" },\n");
3781 printf(" },\n");
3782 ITypeInfo_ReleaseFuncDesc(info, desc);
3783 f++;
3785 printf(" }\n");
3786 printf("},\n");
3787 ITypeInfo_Release(info);
3789 ITypeLib_Release(lib);
3792 #else
3794 typedef struct _element_info
3796 VARTYPE vt;
3797 USHORT wParamFlags;
3798 } element_info;
3800 typedef struct _function_info
3802 MEMBERID memid;
3803 FUNCKIND funckind;
3804 INVOKEKIND invkind;
3805 CALLCONV callconv;
3806 short cParams;
3807 short cParamsOpt;
3808 short vtbl_index;
3809 short cScodes;
3810 WORD wFuncFlags;
3811 element_info ret_type;
3812 element_info params[15];
3813 LPCSTR names[15];
3814 } function_info;
3816 typedef struct _type_info
3818 LPCSTR name;
3819 LPCSTR uuid;
3820 TYPEKIND type;
3821 WORD wTypeFlags;
3822 USHORT cbAlignment;
3823 USHORT cbSizeInstance;
3824 USHORT cbSizeVft;
3825 USHORT cFuncs;
3826 function_info funcs[20];
3827 } type_info;
3829 static const type_info info[] = {
3831 "IDualIface",
3832 "{b14b6bb5-904e-4ff9-b247-bd361f7aaedd}",
3833 /*kind*/ TKIND_DISPATCH, /*flags*/ TYPEFLAG_FDISPATCHABLE|TYPEFLAG_FDUAL, /*align*/ 4, /*size*/ sizeof(void*),
3834 /*#vtbl*/ 7, /*#func*/ 8,
3837 0x60000000, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
3838 /*#param*/ 2, /*#opt*/ 0, /*vtbl*/ 0, /*#scodes*/ 0, /*flags*/ 0x1,
3839 {24, 0}, /* ret */
3840 { /* params */
3841 {26, 1},
3842 {26, 2},
3843 {-1, -1}
3845 { /* names */
3846 "QueryInterface",
3847 "riid",
3848 "ppvObj",
3849 NULL,
3853 0x60000001, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
3854 /*#param*/ 0, /*#opt*/ 0, /*vtbl*/ 1, /*#scodes*/ 0, /*flags*/ 0x1,
3855 {19, 0}, /* ret */
3856 { /* params */
3857 {-1, -1}
3859 { /* names */
3860 "AddRef",
3861 NULL,
3865 0x60000002, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
3866 /*#param*/ 0, /*#opt*/ 0, /*vtbl*/ 2, /*#scodes*/ 0, /*flags*/ 0x1,
3867 {19, 0}, /* ret */
3868 { /* params */
3869 {-1, -1}
3871 { /* names */
3872 "Release",
3873 NULL,
3877 0x60010000, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
3878 /*#param*/ 1, /*#opt*/ 0, /*vtbl*/ 3, /*#scodes*/ 0, /*flags*/ 0x1,
3879 {24, 0}, /* ret */
3880 { /* params */
3881 {26, 2},
3882 {-1, -1}
3884 { /* names */
3885 "GetTypeInfoCount",
3886 "pctinfo",
3887 NULL,
3891 0x60010001, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
3892 /*#param*/ 3, /*#opt*/ 0, /*vtbl*/ 4, /*#scodes*/ 0, /*flags*/ 0x1,
3893 {24, 0}, /* ret */
3894 { /* params */
3895 {23, 1},
3896 {19, 1},
3897 {26, 2},
3898 {-1, -1}
3900 { /* names */
3901 "GetTypeInfo",
3902 "itinfo",
3903 "lcid",
3904 "pptinfo",
3905 NULL,
3909 0x60010002, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
3910 /*#param*/ 5, /*#opt*/ 0, /*vtbl*/ 5, /*#scodes*/ 0, /*flags*/ 0x1,
3911 {24, 0}, /* ret */
3912 { /* params */
3913 {26, 1},
3914 {26, 1},
3915 {23, 1},
3916 {19, 1},
3917 {26, 2},
3918 {-1, -1}
3920 { /* names */
3921 "GetIDsOfNames",
3922 "riid",
3923 "rgszNames",
3924 "cNames",
3925 "lcid",
3926 "rgdispid",
3927 NULL,
3931 0x60010003, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
3932 /*#param*/ 8, /*#opt*/ 0, /*vtbl*/ 6, /*#scodes*/ 0, /*flags*/ 0x1,
3933 {24, 0}, /* ret */
3934 { /* params */
3935 {3, 1},
3936 {26, 1},
3937 {19, 1},
3938 {18, 1},
3939 {26, 1},
3940 {26, 2},
3941 {26, 2},
3942 {26, 2},
3943 {-1, -1}
3945 { /* names */
3946 "Invoke",
3947 "dispidMember",
3948 "riid",
3949 "lcid",
3950 "wFlags",
3951 "pdispparams",
3952 "pvarResult",
3953 "pexcepinfo",
3954 "puArgErr",
3955 NULL,
3959 0x60020000, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
3960 /*#param*/ 0, /*#opt*/ 0, /*vtbl*/ 7, /*#scodes*/ 0, /*flags*/ 0x0,
3961 {24, 0}, /* ret */
3962 { /* params */
3963 {-1, -1}
3965 { /* names */
3966 "Test",
3967 NULL,
3973 "ISimpleIface",
3974 "{ec5dfcd6-eeb0-4cd6-b51e-8030e1dac009}",
3975 /*kind*/ TKIND_INTERFACE, /*flags*/ TYPEFLAG_FDISPATCHABLE, /*align*/ 4, /*size*/ sizeof(void*),
3976 /*#vtbl*/ 8, /*#func*/ 1,
3979 0x60020000, /*func*/ FUNC_PUREVIRTUAL, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
3980 /*#param*/ 0, /*#opt*/ 0, /*vtbl*/ 7, /*#scodes*/ 0, /*flags*/ 0x0,
3981 {25, 0}, /* ret */
3982 { /* params */
3983 {-1, -1}
3985 { /* names */
3986 "Test",
3987 NULL,
3993 "test_struct",
3994 "{4029f190-ca4a-4611-aeb9-673983cb96dd}",
3995 /* kind */ TKIND_RECORD, /*flags*/ 0, /*align*/ 4, /*size*/ sizeof(struct test_struct)
3999 #define check_type(elem, info) { \
4000 expect_int((elem)->tdesc.vt, (info)->vt); \
4001 expect_hex(U(*(elem)).paramdesc.wParamFlags, (info)->wParamFlags); \
4004 static void test_dump_typelib(const char *name)
4006 WCHAR wszName[MAX_PATH];
4007 ITypeLib *typelib;
4008 int ticount = sizeof(info)/sizeof(info[0]);
4009 int iface, func;
4011 MultiByteToWideChar(CP_ACP, 0, name, -1, wszName, MAX_PATH);
4012 ole_check(LoadTypeLibEx(wszName, REGKIND_NONE, &typelib));
4013 expect_eq(ITypeLib_GetTypeInfoCount(typelib), ticount, UINT, "%d");
4014 for (iface = 0; iface < ticount; iface++)
4016 const type_info *ti = &info[iface];
4017 ITypeInfo *typeinfo;
4018 TYPEATTR *typeattr;
4019 BSTR bstrIfName;
4021 trace("Interface %s\n", ti->name);
4022 ole_check(ITypeLib_GetTypeInfo(typelib, iface, &typeinfo));
4023 ole_check(ITypeLib_GetDocumentation(typelib, iface, &bstrIfName, NULL, NULL, NULL));
4024 expect_wstr_acpval(bstrIfName, ti->name);
4025 SysFreeString(bstrIfName);
4027 ole_check(ITypeInfo_GetTypeAttr(typeinfo, &typeattr));
4028 expect_int(typeattr->typekind, ti->type);
4029 expect_hex(typeattr->wTypeFlags, ti->wTypeFlags);
4030 expect_int(typeattr->cbAlignment, ti->cbAlignment);
4031 expect_int(typeattr->cbSizeInstance, ti->cbSizeInstance);
4032 expect_int(typeattr->cbSizeVft, ti->cbSizeVft * sizeof(void*));
4033 expect_int(typeattr->cFuncs, ti->cFuncs);
4035 /* compare type uuid */
4036 if (ti->uuid && *ti->uuid)
4038 WCHAR guidW[39];
4039 ITypeInfo *typeinfo2;
4040 HRESULT hr;
4041 GUID guid;
4043 MultiByteToWideChar(CP_ACP, 0, ti->uuid, -1, guidW, sizeof(guidW)/sizeof(guidW[0]));
4044 IIDFromString(guidW, &guid);
4045 expect_guid(&guid, &typeattr->guid);
4047 /* check that it's possible to search using this uuid */
4048 typeinfo2 = NULL;
4049 hr = ITypeLib_GetTypeInfoOfGuid(typelib, &guid, &typeinfo2);
4050 ok(hr == S_OK, "got 0x%08x\n", hr);
4051 ITypeInfo_Release(typeinfo2);
4054 for (func = 0; func < typeattr->cFuncs; func++)
4056 function_info *fn_info = (function_info *)&ti->funcs[func];
4057 FUNCDESC *desc;
4058 BSTR namesTab[256];
4059 UINT cNames;
4060 int i;
4062 trace("Function %s\n", fn_info->names[0]);
4063 ole_check(ITypeInfo_GetFuncDesc(typeinfo, func, &desc));
4064 expect_int(desc->memid, fn_info->memid);
4065 expect_int(desc->funckind, fn_info->funckind);
4066 expect_int(desc->invkind, fn_info->invkind);
4067 expect_int(desc->callconv, fn_info->callconv);
4068 expect_int(desc->cParams, fn_info->cParams);
4069 expect_int(desc->cParamsOpt, fn_info->cParamsOpt);
4070 ok( desc->oVft == fn_info->vtbl_index * sizeof(void*) ||
4071 broken(desc->oVft == fn_info->vtbl_index * 4), /* xp64 */
4072 "desc->oVft got %u\n", desc->oVft );
4073 expect_int(desc->cScodes, fn_info->cScodes);
4074 expect_int(desc->wFuncFlags, fn_info->wFuncFlags);
4075 ole_check(ITypeInfo_GetNames(typeinfo, desc->memid, namesTab, 256, &cNames));
4076 for (i = 0; i < cNames; i++)
4078 expect_wstr_acpval(namesTab[i], fn_info->names[i]);
4079 SysFreeString(namesTab[i]);
4081 expect_null(fn_info->names[cNames]);
4083 check_type(&desc->elemdescFunc, &fn_info->ret_type);
4084 for (i = 0 ; i < desc->cParams; i++)
4086 check_type(&desc->lprgelemdescParam[i], &fn_info->params[i]);
4088 expect_int(fn_info->params[desc->cParams].vt, (VARTYPE)-1);
4090 ITypeInfo_ReleaseFuncDesc(typeinfo, desc);
4093 ITypeInfo_ReleaseTypeAttr(typeinfo, typeattr);
4094 ITypeInfo_Release(typeinfo);
4096 ITypeLib_Release(typelib);
4099 #endif
4101 static void test_create_typelib_lcid(LCID lcid)
4103 char filename[MAX_PATH];
4104 WCHAR name[MAX_PATH];
4105 HRESULT hr;
4106 ICreateTypeLib2 *tl;
4107 HANDLE file;
4108 DWORD msft_header[8];
4109 ITypeLib *typelib;
4110 TLIBATTR *attr;
4111 DWORD read;
4113 GetTempFileNameA( ".", "tlb", 0, filename );
4114 MultiByteToWideChar(CP_ACP, 0, filename, -1, name, MAX_PATH);
4116 hr = CreateTypeLib2(SYS_WIN32, name, &tl);
4117 ok(hr == S_OK, "got %08x\n", hr);
4119 hr = ICreateTypeLib2_QueryInterface(tl, &IID_ITypeLib, (void**)&typelib);
4120 ok(hr == S_OK, "got %08x\n", hr);
4122 hr = ITypeLib_GetLibAttr(typelib, &attr);
4123 ok(hr == S_OK, "got %08x\n", hr);
4124 ok(attr->wLibFlags == 0, "flags 0x%x\n", attr->wLibFlags);
4125 ITypeLib_ReleaseTLibAttr(typelib, attr);
4127 hr = ICreateTypeLib2_SetLcid(tl, lcid);
4128 ok(hr == S_OK, "got %08x\n", hr);
4130 hr = ICreateTypeLib2_SetVersion(tl, 3, 4);
4131 ok(hr == S_OK, "got %08x\n", hr);
4133 hr = ICreateTypeLib2_SaveAllChanges(tl);
4134 ok(hr == S_OK, "got %08x\n", hr);
4136 hr = ITypeLib_GetLibAttr(typelib, &attr);
4137 ok(hr == S_OK, "got %08x\n", hr);
4138 ok(attr->wLibFlags == 0, "flags 0x%x\n", attr->wLibFlags);
4139 ITypeLib_ReleaseTLibAttr(typelib, attr);
4141 ITypeLib_Release(typelib);
4142 ICreateTypeLib2_Release(tl);
4144 file = CreateFileA( filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0 );
4145 ok( file != INVALID_HANDLE_VALUE, "file creation failed\n" );
4147 ReadFile( file, msft_header, sizeof(msft_header), &read, NULL );
4148 ok(read == sizeof(msft_header), "read %d\n", read);
4149 CloseHandle( file );
4151 ok(msft_header[0] == 0x5446534d, "got %08x\n", msft_header[0]);
4152 ok(msft_header[1] == 0x00010002, "got %08x\n", msft_header[1]);
4153 ok(msft_header[2] == 0xffffffff, "got %08x\n", msft_header[2]);
4154 ok(msft_header[3] == (lcid ? lcid : 0x409), "got %08x (lcid %08x)\n", msft_header[3], lcid);
4155 ok(msft_header[4] == lcid, "got %08x (lcid %08x)\n", msft_header[4], lcid);
4156 ok(msft_header[6] == 0x00040003, "got %08x\n", msft_header[6]);
4157 ok(msft_header[7] == 0, "got %08x\n", msft_header[7]);
4159 /* check flags after loading */
4160 hr = LoadTypeLib(name, &typelib);
4161 ok(hr == S_OK, "got %08x\n", hr);
4163 hr = ITypeLib_GetLibAttr(typelib, &attr);
4164 ok(hr == S_OK, "got %08x\n", hr);
4165 ok(attr->wLibFlags == LIBFLAG_FHASDISKIMAGE, "flags 0x%x\n", attr->wLibFlags);
4166 ITypeLib_ReleaseTLibAttr(typelib, attr);
4167 ITypeLib_Release(typelib);
4169 DeleteFileA(filename);
4172 static void test_create_typelibs(void)
4174 test_create_typelib_lcid(LOCALE_SYSTEM_DEFAULT);
4175 test_create_typelib_lcid(LOCALE_USER_DEFAULT);
4176 test_create_typelib_lcid(LOCALE_NEUTRAL);
4178 test_create_typelib_lcid(0x009);
4179 test_create_typelib_lcid(0x409);
4180 test_create_typelib_lcid(0x809);
4182 test_create_typelib_lcid(0x007);
4183 test_create_typelib_lcid(0x407);
4187 static void test_register_typelib(BOOL system_registration)
4189 HRESULT hr;
4190 WCHAR filename[MAX_PATH];
4191 const char *filenameA;
4192 ITypeLib *typelib;
4193 WCHAR uuidW[40];
4194 char key_name[MAX_PATH], uuid[40];
4195 LONG ret, expect_ret;
4196 UINT count, i;
4197 HKEY hkey;
4198 struct
4200 TYPEKIND kind;
4201 WORD flags;
4202 } attrs[12] =
4204 { TKIND_INTERFACE, 0 },
4205 { TKIND_INTERFACE, TYPEFLAG_FDISPATCHABLE },
4206 { TKIND_INTERFACE, TYPEFLAG_FOLEAUTOMATION },
4207 { TKIND_INTERFACE, TYPEFLAG_FDISPATCHABLE | TYPEFLAG_FOLEAUTOMATION },
4208 { TKIND_DISPATCH, 0 /* TYPEFLAG_FDUAL - widl clears this flag for non-IDispatch derived interfaces */ },
4209 { TKIND_DISPATCH, 0 /* TYPEFLAG_FDUAL - widl clears this flag for non-IDispatch derived interfaces */ },
4210 { TKIND_DISPATCH, TYPEFLAG_FDISPATCHABLE | TYPEFLAG_FDUAL },
4211 { TKIND_DISPATCH, TYPEFLAG_FDISPATCHABLE | TYPEFLAG_FDUAL },
4212 { TKIND_DISPATCH, TYPEFLAG_FDISPATCHABLE },
4213 { TKIND_DISPATCH, TYPEFLAG_FDISPATCHABLE },
4214 { TKIND_DISPATCH, TYPEFLAG_FDISPATCHABLE },
4215 { TKIND_INTERFACE, TYPEFLAG_FDISPATCHABLE }
4218 trace("Starting %s typelib registration tests\n",
4219 system_registration ? "system" : "user");
4221 if (!system_registration && (!pRegisterTypeLibForUser || !pUnRegisterTypeLibForUser))
4223 win_skip("User typelib registration functions are not available\n");
4224 return;
4227 filenameA = create_test_typelib(3);
4228 MultiByteToWideChar(CP_ACP, 0, filenameA, -1, filename, MAX_PATH);
4230 hr = LoadTypeLibEx(filename, REGKIND_NONE, &typelib);
4231 ok(hr == S_OK, "got %08x\n", hr);
4233 if (system_registration)
4234 hr = RegisterTypeLib(typelib, filename, NULL);
4235 else
4236 hr = pRegisterTypeLibForUser(typelib, filename, NULL);
4237 if (hr == TYPE_E_REGISTRYACCESS)
4239 win_skip("Insufficient privileges to register typelib in the registry\n");
4240 ITypeLib_Release(typelib);
4241 DeleteFileA(filenameA);
4242 return;
4244 ok(hr == S_OK, "got %08x\n", hr);
4246 count = ITypeLib_GetTypeInfoCount(typelib);
4247 ok(count == 12, "got %d\n", count);
4249 for(i = 0; i < count; i++)
4251 ITypeInfo *typeinfo;
4252 TYPEATTR *attr;
4253 REGSAM opposite = (sizeof(void*) == 8 ? KEY_WOW64_32KEY : KEY_WOW64_64KEY);
4255 hr = ITypeLib_GetTypeInfo(typelib, i, &typeinfo);
4256 ok(hr == S_OK, "got %08x\n", hr);
4258 hr = ITypeInfo_GetTypeAttr(typeinfo, &attr);
4259 ok(hr == S_OK, "got %08x\n", hr);
4261 ok(attr->typekind == attrs[i].kind, "%d: got kind %d\n", i, attr->typekind);
4262 ok(attr->wTypeFlags == attrs[i].flags, "%d: got flags %04x\n", i, attr->wTypeFlags);
4264 if(attr->typekind == TKIND_DISPATCH && (attr->wTypeFlags & TYPEFLAG_FDUAL))
4266 HREFTYPE reftype;
4267 ITypeInfo *dual_info;
4268 TYPEATTR *dual_attr;
4270 hr = ITypeInfo_GetRefTypeOfImplType(typeinfo, -1, &reftype);
4271 ok(hr == S_OK, "got %08x\n", hr);
4273 hr = ITypeInfo_GetRefTypeInfo(typeinfo, reftype, &dual_info);
4274 ok(hr == S_OK, "got %08x\n", hr);
4276 hr = ITypeInfo_GetTypeAttr(dual_info, &dual_attr);
4277 ok(hr == S_OK, "got %08x\n", hr);
4279 ok(dual_attr->typekind == TKIND_INTERFACE, "%d: got kind %d\n", i, dual_attr->typekind);
4280 ok(dual_attr->wTypeFlags == (TYPEFLAG_FDISPATCHABLE | TYPEFLAG_FOLEAUTOMATION | TYPEFLAG_FDUAL), "%d: got flags %04x\n", i, dual_attr->wTypeFlags);
4282 ITypeInfo_ReleaseTypeAttr(dual_info, dual_attr);
4283 ITypeInfo_Release(dual_info);
4287 StringFromGUID2(&attr->guid, uuidW, sizeof(uuidW) / sizeof(uuidW[0]));
4288 WideCharToMultiByte(CP_ACP, 0, uuidW, -1, uuid, sizeof(uuid), NULL, NULL);
4289 sprintf(key_name, "Interface\\%s", uuid);
4291 /* All dispinterfaces will be registered (this includes dual interfaces) as well
4292 as oleautomation interfaces */
4293 if((attr->typekind == TKIND_INTERFACE && (attr->wTypeFlags & TYPEFLAG_FOLEAUTOMATION)) ||
4294 attr->typekind == TKIND_DISPATCH)
4295 expect_ret = ERROR_SUCCESS;
4296 else
4297 expect_ret = ERROR_FILE_NOT_FOUND;
4299 ret = RegOpenKeyExA(HKEY_CLASSES_ROOT, key_name, 0, KEY_READ, &hkey);
4300 ok(ret == expect_ret, "%d: got %d\n", i, ret);
4301 if(ret == ERROR_SUCCESS) RegCloseKey(hkey);
4303 /* 32-bit typelibs should be registered into both registry bit modes */
4304 ret = RegOpenKeyExA(HKEY_CLASSES_ROOT, key_name, 0, KEY_READ | opposite, &hkey);
4305 ok(ret == expect_ret, "%d: got %d\n", i, ret);
4306 if(ret == ERROR_SUCCESS) RegCloseKey(hkey);
4308 ITypeInfo_ReleaseTypeAttr(typeinfo, attr);
4309 ITypeInfo_Release(typeinfo);
4312 if (system_registration)
4313 hr = UnRegisterTypeLib(&LIBID_register_test, 1, 0, LOCALE_NEUTRAL, is_win64 ? SYS_WIN64 : SYS_WIN32);
4314 else
4315 hr = pUnRegisterTypeLibForUser(&LIBID_register_test, 1, 0, LOCALE_NEUTRAL, is_win64 ? SYS_WIN64 : SYS_WIN32);
4316 ok(hr == S_OK, "got %08x\n", hr);
4318 ITypeLib_Release(typelib);
4319 DeleteFileA( filenameA );
4322 static void test_LoadTypeLib(void)
4324 ITypeLib *tl;
4325 HRESULT hres;
4327 static const WCHAR kernel32_dllW[] = {'k','e','r','n','e','l','3','2','.','d','l','l',0};
4329 hres = LoadTypeLib(kernel32_dllW, &tl);
4330 ok(hres == TYPE_E_CANTLOADLIBRARY, "LoadTypeLib returned: %08x, expected TYPE_E_CANTLOADLIBRARY\n", hres);
4333 static void test_SetVarHelpContext(void)
4335 static OLECHAR nameW[] = {'n','a','m','e',0};
4336 CHAR filenameA[MAX_PATH];
4337 WCHAR filenameW[MAX_PATH];
4338 ICreateTypeLib2 *ctl;
4339 ICreateTypeInfo *cti;
4340 ITypeLib *tl;
4341 ITypeInfo *ti;
4342 VARDESC desc, *pdesc;
4343 HRESULT hr;
4344 DWORD ctx;
4345 VARIANT v;
4347 GetTempFileNameA(".", "tlb", 0, filenameA);
4348 MultiByteToWideChar(CP_ACP, 0, filenameA, -1, filenameW, MAX_PATH);
4350 hr = CreateTypeLib2(SYS_WIN32, filenameW, &ctl);
4351 ok(hr == S_OK, "got %08x\n", hr);
4353 hr = ICreateTypeLib2_CreateTypeInfo(ctl, nameW, TKIND_ENUM, &cti);
4354 ok(hr == S_OK, "got %08x\n", hr);
4356 hr = ICreateTypeInfo_SetVarHelpContext(cti, 0, 0);
4357 ok(hr == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hr);
4359 memset(&desc, 0, sizeof(desc));
4360 desc.memid = MEMBERID_NIL;
4361 desc.elemdescVar.tdesc.vt = VT_INT;
4362 desc.varkind = VAR_CONST;
4364 V_VT(&v) = VT_INT;
4365 V_INT(&v) = 1;
4366 U(desc).lpvarValue = &v;
4367 hr = ICreateTypeInfo_AddVarDesc(cti, 0, &desc);
4368 ok(hr == S_OK, "got %08x\n", hr);
4370 hr = ICreateTypeInfo_SetVarHelpContext(cti, 0, 0);
4371 ok(hr == S_OK, "got %08x\n", hr);
4373 /* another time */
4374 hr = ICreateTypeInfo_SetVarHelpContext(cti, 0, 1);
4375 ok(hr == S_OK, "got %08x\n", hr);
4377 /* wrong index now */
4378 hr = ICreateTypeInfo_SetVarHelpContext(cti, 1, 0);
4379 ok(hr == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hr);
4381 ICreateTypeInfo_Release(cti);
4383 hr = ICreateTypeLib2_SaveAllChanges(ctl);
4384 ok(hr == S_OK, "got: %08x\n", hr);
4386 ICreateTypeLib2_Release(ctl);
4388 hr = LoadTypeLib(filenameW, &tl);
4389 ok(hr == S_OK, "got: %08x\n", hr);
4391 hr = ITypeLib_GetTypeInfo(tl, 0, &ti);
4392 ok(hr == S_OK, "got %08x\n", hr);
4394 hr = ITypeInfo_GetVarDesc(ti, 0, &pdesc);
4395 ok(hr == S_OK, "got %08x\n", hr);
4396 ok(pdesc->memid == 0x40000000, "got wrong memid: %x\n", pdesc->memid);
4397 ok(pdesc->elemdescVar.tdesc.vt == VT_INT, "got wrong vardesc type: %u\n", pdesc->elemdescVar.tdesc.vt);
4398 ok(pdesc->varkind == VAR_CONST, "got wrong varkind: %u\n", pdesc->varkind);
4399 ok(V_VT(U(*pdesc).lpvarValue) == VT_INT, "got wrong value type: %u\n", V_VT(U(*pdesc).lpvarValue));
4400 ok(V_INT(U(*pdesc).lpvarValue) == 1, "got wrong value: 0x%x\n", V_INT(U(*pdesc).lpvarValue));
4402 hr = ITypeInfo_GetDocumentation(ti, pdesc->memid, NULL, NULL, &ctx, NULL);
4403 ok(hr == S_OK, "got %08x\n", hr);
4404 ok(ctx == 1, "got wrong help context: 0x%x\n", ctx);
4406 ITypeInfo_ReleaseVarDesc(ti, pdesc);
4407 ITypeInfo_Release(ti);
4408 ITypeLib_Release(tl);
4410 DeleteFileA(filenameA);
4413 static void test_SetFuncAndParamNames(void)
4415 static OLECHAR nameW[] = {'n','a','m','e',0};
4416 static OLECHAR name2W[] = {'n','a','m','e','2',0};
4417 static OLECHAR prop[] = {'p','r','o','p',0};
4418 static OLECHAR *propW[] = {prop};
4419 static OLECHAR func[] = {'f','u','n','c',0};
4420 static OLECHAR *funcW[] = {func, NULL};
4421 CHAR filenameA[MAX_PATH];
4422 WCHAR filenameW[MAX_PATH];
4423 ICreateTypeLib2 *ctl;
4424 ICreateTypeInfo *cti;
4425 ITypeLib *tl;
4426 ITypeInfo *infos[3];
4427 MEMBERID memids[3];
4428 FUNCDESC funcdesc;
4429 ELEMDESC edesc;
4430 HRESULT hr;
4431 USHORT found;
4433 GetTempFileNameA(".", "tlb", 0, filenameA);
4434 MultiByteToWideChar(CP_ACP, 0, filenameA, -1, filenameW, MAX_PATH);
4436 hr = CreateTypeLib2(SYS_WIN32, filenameW, &ctl);
4437 ok(hr == S_OK, "got %08x\n", hr);
4439 hr = ICreateTypeLib2_CreateTypeInfo(ctl, nameW, TKIND_DISPATCH, &cti);
4440 ok(hr == S_OK, "got %08x\n", hr);
4442 /* get method */
4443 memset(&funcdesc, 0, sizeof(FUNCDESC));
4444 funcdesc.funckind = FUNC_DISPATCH;
4445 funcdesc.callconv = CC_STDCALL;
4446 funcdesc.elemdescFunc.tdesc.vt = VT_VOID;
4447 funcdesc.wFuncFlags = FUNCFLAG_FBINDABLE;
4449 /* put method */
4450 memset(&edesc, 0, sizeof(edesc));
4451 edesc.tdesc.vt = VT_BSTR;
4452 U(edesc).idldesc.dwReserved = 0;
4453 U(edesc).idldesc.wIDLFlags = IDLFLAG_FIN;
4455 funcdesc.lprgelemdescParam = &edesc;
4456 funcdesc.invkind = INVOKE_PROPERTYPUT;
4457 funcdesc.cParams = 1;
4459 hr = ICreateTypeInfo_AddFuncDesc(cti, 0, &funcdesc);
4460 ok(hr == S_OK, "got 0x%08x\n", hr);
4462 /* setter name */
4463 hr = ICreateTypeInfo_SetFuncAndParamNames(cti, 0, propW, 1);
4464 ok(hr == S_OK, "got 0x%08x\n", hr);
4466 /* putref method */
4467 funcdesc.invkind = INVOKE_PROPERTYPUTREF;
4468 hr = ICreateTypeInfo_AddFuncDesc(cti, 1, &funcdesc);
4469 ok(hr == S_OK, "got 0x%08x\n", hr);
4471 /* putref name */
4472 hr = ICreateTypeInfo_SetFuncAndParamNames(cti, 1, propW, 1);
4473 ok(hr == S_OK, "got 0x%08x\n", hr);
4475 funcdesc.invkind = INVOKE_PROPERTYGET;
4476 funcdesc.cParams = 0;
4477 hr = ICreateTypeInfo_AddFuncDesc(cti, 2, &funcdesc);
4478 ok(hr == S_OK, "got 0x%08x\n", hr);
4480 /* getter name */
4481 hr = ICreateTypeInfo_SetFuncAndParamNames(cti, 2, propW, 1);
4482 ok(hr == S_OK, "got 0x%08x\n", hr);
4484 hr = ICreateTypeInfo_AddFuncDesc(cti, 3, &funcdesc);
4485 ok(hr == S_OK, "got 0x%08x\n", hr);
4487 /* getter name again */
4488 hr = ICreateTypeInfo_SetFuncAndParamNames(cti, 3, propW, 1);
4489 ok(hr == TYPE_E_AMBIGUOUSNAME, "got 0x%08x\n", hr);
4491 /* regular function */
4492 funcdesc.invkind = INVOKE_FUNC;
4493 funcdesc.cParams = 1;
4494 hr = ICreateTypeInfo_AddFuncDesc(cti, 4, &funcdesc);
4495 ok(hr == S_OK, "got 0x%08x\n", hr);
4497 hr = ICreateTypeInfo_SetFuncAndParamNames(cti, 4, funcW, 2);
4498 ok(hr == S_OK, "got 0x%08x\n", hr);
4500 ICreateTypeInfo_Release(cti);
4502 hr = ICreateTypeLib2_CreateTypeInfo(ctl, name2W, TKIND_INTERFACE, &cti);
4503 ok(hr == S_OK, "got %08x\n", hr);
4505 funcdesc.funckind = FUNC_PUREVIRTUAL;
4506 funcdesc.invkind = INVOKE_FUNC;
4507 funcdesc.cParams = 0;
4508 funcdesc.lprgelemdescParam = NULL;
4509 hr = ICreateTypeInfo_AddFuncDesc(cti, 0, &funcdesc);
4510 ok(hr == S_OK, "got 0x%08x\n", hr);
4512 hr = ICreateTypeInfo_SetFuncAndParamNames(cti, 0, funcW, 1);
4513 ok(hr == S_OK, "got 0x%08x\n", hr);
4515 ICreateTypeInfo_Release(cti);
4517 hr = ICreateTypeLib2_QueryInterface(ctl, &IID_ITypeLib, (void**)&tl);
4518 ok(hr == S_OK, "got %08x\n", hr);
4520 found = 1;
4521 memset(infos, 0, sizeof(infos));
4522 memids[0] = 0xdeadbeef;
4523 memids[1] = 0xdeadbeef;
4524 memids[2] = 0xdeadbeef;
4525 hr = ITypeLib_FindName(tl, func, 0, infos, memids, &found);
4526 ok(hr == S_OK, "got %08x\n", hr);
4527 ok(found == 1, "got wrong count: %u\n", found);
4528 ok(infos[0] && !infos[1] && !infos[2], "got wrong typeinfo\n");
4529 ok(memids[0] == 0, "got wrong memid[0]\n");
4530 ok(memids[1] == 0xdeadbeef && memids[2] == 0xdeadbeef, "got wrong memids\n");
4532 found = 3;
4533 memset(infos, 0, sizeof(infos));
4534 memids[0] = 0xdeadbeef;
4535 memids[1] = 0xdeadbeef;
4536 memids[2] = 0xdeadbeef;
4537 hr = ITypeLib_FindName(tl, func, 0, infos, memids, &found);
4538 ok(hr == S_OK, "got %08x\n", hr);
4539 ok(found == 2, "got wrong count: %u\n", found);
4540 ok(infos[0] && infos[1] && infos[0] != infos[1], "got same typeinfo\n");
4541 ok(memids[0] == 0, "got wrong memid[0]\n");
4542 ok(memids[1] == 0, "got wrong memid[1]\n");
4544 ITypeLib_Release(tl);
4545 ICreateTypeLib2_Release(ctl);
4546 DeleteFileA(filenameA);
4549 static void test_SetDocString(void)
4551 static OLECHAR nameW[] = {'n','a','m','e',0};
4552 static OLECHAR name2W[] = {'n','a','m','e','2',0};
4553 static OLECHAR doc1W[] = {'d','o','c','1',0};
4554 static OLECHAR doc2W[] = {'d','o','c','2',0};
4555 static OLECHAR var_nameW[] = {'v','a','r','n','a','m','e',0};
4556 CHAR filenameA[MAX_PATH];
4557 WCHAR filenameW[MAX_PATH];
4558 ICreateTypeLib2 *ctl;
4559 ICreateTypeInfo *cti;
4560 ITypeLib *tl;
4561 ITypeInfo *ti;
4562 BSTR namestr, docstr;
4563 VARDESC desc, *pdesc;
4564 FUNCDESC funcdesc, *pfuncdesc;
4565 HRESULT hr;
4566 VARIANT v;
4568 GetTempFileNameA(".", "tlb", 0, filenameA);
4569 MultiByteToWideChar(CP_ACP, 0, filenameA, -1, filenameW, MAX_PATH);
4571 hr = CreateTypeLib2(SYS_WIN32, filenameW, &ctl);
4572 ok(hr == S_OK, "got %08x\n", hr);
4574 hr = ICreateTypeLib2_CreateTypeInfo(ctl, nameW, TKIND_ENUM, &cti);
4575 ok(hr == S_OK, "got %08x\n", hr);
4577 hr = ICreateTypeInfo_SetVarDocString(cti, 0, doc1W);
4578 ok(hr == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hr);
4580 hr = ICreateTypeInfo_SetVarDocString(cti, 0, NULL);
4581 ok(hr == E_INVALIDARG, "got %08x\n", hr);
4583 memset(&desc, 0, sizeof(desc));
4584 desc.memid = MEMBERID_NIL;
4585 desc.elemdescVar.tdesc.vt = VT_INT;
4586 desc.varkind = VAR_CONST;
4588 V_VT(&v) = VT_INT;
4589 V_INT(&v) = 1;
4590 U(desc).lpvarValue = &v;
4591 hr = ICreateTypeInfo_AddVarDesc(cti, 0, &desc);
4592 ok(hr == S_OK, "got %08x\n", hr);
4594 hr = ICreateTypeInfo_SetVarName(cti, 0, NULL);
4595 ok(hr == E_INVALIDARG, "got %08x\n", hr);
4597 hr = ICreateTypeInfo_SetVarName(cti, 1, var_nameW);
4598 ok(hr == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hr);
4600 hr = ICreateTypeInfo_SetVarName(cti, 0, var_nameW);
4601 ok(hr == S_OK, "got %08x\n", hr);
4603 hr = ICreateTypeInfo_SetVarDocString(cti, 0, NULL);
4604 ok(hr == E_INVALIDARG, "got %08x\n", hr);
4606 hr = ICreateTypeInfo_SetVarDocString(cti, 0, doc1W);
4607 ok(hr == S_OK, "got %08x\n", hr);
4609 /* already set */
4610 hr = ICreateTypeInfo_SetVarDocString(cti, 0, doc2W);
4611 ok(hr == S_OK, "got %08x\n", hr);
4613 /* wrong index now */
4614 hr = ICreateTypeInfo_SetVarDocString(cti, 1, doc1W);
4615 ok(hr == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hr);
4617 ICreateTypeInfo_Release(cti);
4619 hr = ICreateTypeLib2_CreateTypeInfo(ctl, name2W, TKIND_INTERFACE, &cti);
4620 ok(hr == S_OK, "got %08x\n", hr);
4622 hr = ICreateTypeInfo_SetFuncDocString(cti, 0, doc1W);
4623 ok(hr == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hr);
4625 hr = ICreateTypeInfo_SetFuncDocString(cti, 0, NULL);
4626 ok(hr == E_INVALIDARG, "got %08x\n", hr);
4628 memset(&funcdesc, 0, sizeof(funcdesc));
4629 funcdesc.memid = MEMBERID_NIL;
4630 funcdesc.funckind = FUNC_PUREVIRTUAL;
4631 funcdesc.invkind = INVOKE_FUNC;
4632 funcdesc.callconv = CC_STDCALL;
4634 hr = ICreateTypeInfo_AddFuncDesc(cti, 0, &funcdesc);
4635 ok(hr == S_OK, "got %08x\n", hr);
4637 hr = ICreateTypeInfo_SetFuncDocString(cti, 0, doc1W);
4638 ok(hr == S_OK, "got %08x\n", hr);
4640 ICreateTypeInfo_Release(cti);
4642 hr = ICreateTypeLib2_SaveAllChanges(ctl);
4643 ok(hr == S_OK, "got: %08x\n", hr);
4645 ICreateTypeLib2_Release(ctl);
4647 hr = LoadTypeLib(filenameW, &tl);
4648 ok(hr == S_OK, "got: %08x\n", hr);
4650 hr = ITypeLib_GetTypeInfo(tl, 0, &ti);
4651 ok(hr == S_OK, "got %08x\n", hr);
4653 hr = ITypeInfo_GetVarDesc(ti, 0, &pdesc);
4654 ok(hr == S_OK, "got %08x\n", hr);
4655 ok(pdesc->memid == 0x40000000, "got wrong memid: %x\n", pdesc->memid);
4656 ok(pdesc->elemdescVar.tdesc.vt == VT_INT, "got wrong vardesc type: %u\n", pdesc->elemdescVar.tdesc.vt);
4657 ok(pdesc->varkind == VAR_CONST, "got wrong varkind: %u\n", pdesc->varkind);
4658 ok(V_VT(U(*pdesc).lpvarValue) == VT_INT, "got wrong value type: %u\n", V_VT(U(*pdesc).lpvarValue));
4659 ok(V_INT(U(*pdesc).lpvarValue) == 1, "got wrong value: 0x%x\n", V_INT(U(*pdesc).lpvarValue));
4661 hr = ITypeInfo_GetDocumentation(ti, pdesc->memid, &namestr, &docstr, NULL, NULL);
4662 ok(hr == S_OK, "got %08x\n", hr);
4663 ok(memcmp(namestr, var_nameW, sizeof(var_nameW)) == 0, "got wrong name: %s\n", wine_dbgstr_w(namestr));
4664 ok(memcmp(docstr, doc2W, sizeof(doc2W)) == 0, "got wrong docstring: %s\n", wine_dbgstr_w(docstr));
4666 SysFreeString(namestr);
4667 SysFreeString(docstr);
4669 ITypeInfo_ReleaseVarDesc(ti, pdesc);
4670 ITypeInfo_Release(ti);
4672 hr = ITypeLib_GetTypeInfo(tl, 1, &ti);
4673 ok(hr == S_OK, "got %08x\n", hr);
4675 hr = ITypeInfo_GetFuncDesc(ti, 0, &pfuncdesc);
4676 ok(hr == S_OK, "got %08x\n", hr);
4677 ok(pfuncdesc->memid == 0x60000000, "got wrong memid: %x\n", pfuncdesc->memid);
4678 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got wrong funckind: %x\n", pfuncdesc->funckind);
4679 ok(pfuncdesc->invkind == INVOKE_FUNC, "got wrong invkind: %x\n", pfuncdesc->invkind);
4680 ok(pfuncdesc->callconv == CC_STDCALL, "got wrong callconv: %x\n", pfuncdesc->callconv);
4682 hr = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &namestr, &docstr, NULL, NULL);
4683 ok(hr == S_OK, "got %08x\n", hr);
4684 ok(namestr == NULL, "got wrong name: %s\n", wine_dbgstr_w(namestr));
4685 ok(memcmp(docstr, doc1W, sizeof(doc1W)) == 0, "got wrong docstring: %s\n", wine_dbgstr_w(docstr));
4687 SysFreeString(docstr);
4689 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
4690 ITypeInfo_Release(ti);
4692 ITypeLib_Release(tl);
4694 DeleteFileA(filenameA);
4697 static void test_FindName(void)
4699 static const WCHAR invalidW[] = {'i','n','v','a','l','i','d',0};
4700 WCHAR buffW[100];
4701 MEMBERID memid;
4702 ITypeInfo *ti;
4703 ITypeLib *tl;
4704 HRESULT hr;
4705 UINT16 c;
4707 hr = LoadTypeLib(wszStdOle2, &tl);
4708 ok(hr == S_OK, "got 0x%08x\n", hr);
4710 hr = ITypeLib_FindName(tl, NULL, 0, NULL, NULL, NULL);
4711 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
4713 lstrcpyW(buffW, wszGUID);
4714 hr = ITypeLib_FindName(tl, buffW, 0, NULL, NULL, NULL);
4715 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
4717 c = 0;
4718 ti = (void*)0xdeadbeef;
4719 hr = ITypeLib_FindName(tl, buffW, 0, &ti, NULL, &c);
4720 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
4721 ok(c == 0, "got %d\n", c);
4722 ok(ti == (void*)0xdeadbeef, "got %p\n", ti);
4724 c = 1;
4725 ti = (void*)0xdeadbeef;
4726 hr = ITypeLib_FindName(tl, buffW, 0, &ti, NULL, &c);
4727 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
4728 ok(c == 1, "got %d\n", c);
4729 ok(ti == (void*)0xdeadbeef, "got %p\n", ti);
4731 c = 1;
4732 memid = 0;
4733 ti = (void*)0xdeadbeef;
4734 hr = ITypeLib_FindName(tl, buffW, 0, &ti, &memid, &c);
4735 ok(hr == S_OK, "got 0x%08x\n", hr);
4736 ok(memid == MEMBERID_NIL, "got %d\n", memid);
4737 ok(!lstrcmpW(buffW, wszGUID), "got %s\n", wine_dbgstr_w(buffW));
4738 ok(c == 1, "got %d\n", c);
4739 ITypeInfo_Release(ti);
4741 c = 1;
4742 memid = 0;
4743 lstrcpyW(buffW, wszguid);
4744 ti = (void*)0xdeadbeef;
4745 hr = ITypeLib_FindName(tl, buffW, 0, &ti, &memid, &c);
4746 ok(hr == S_OK, "got 0x%08x\n", hr);
4747 todo_wine {
4748 ok(memid == MEMBERID_NIL, "got %d\n", memid);
4749 ok(!lstrcmpW(buffW, wszGUID), "got %s\n", wine_dbgstr_w(buffW));
4750 ok(c == 1, "got %d\n", c);
4752 if (c == 1)
4753 ITypeInfo_Release(ti);
4755 c = 1;
4756 memid = -1;
4757 lstrcpyW(buffW, invalidW);
4758 ti = (void*)0xdeadbeef;
4759 hr = ITypeLib_FindName(tl, buffW, 0, &ti, &memid, &c);
4760 ok(hr == S_OK, "got 0x%08x\n", hr);
4761 ok(memid == MEMBERID_NIL, "got %d\n", memid);
4762 ok(!lstrcmpW(buffW, invalidW), "got %s\n", wine_dbgstr_w(buffW));
4763 ok(c == 0, "got %d\n", c);
4764 ok(ti == (void*)0xdeadbeef, "got %p\n", ti);
4766 ITypeLib_Release(tl);
4769 static void test_TypeInfo2_GetContainingTypeLib(void)
4771 static const WCHAR test[] = {'t','e','s','t','.','t','l','b',0};
4772 static OLECHAR testTI[] = {'t','e','s','t','T','y','p','e','I','n','f','o',0};
4774 ICreateTypeLib2 *ctl2;
4775 ICreateTypeInfo *cti;
4776 ITypeInfo2 *ti2;
4777 ITypeLib *tl;
4778 UINT Index;
4779 HRESULT hr;
4781 hr = CreateTypeLib2(SYS_WIN32, test, &ctl2);
4782 ok_ole_success(hr, CreateTypeLib2);
4784 hr = ICreateTypeLib2_CreateTypeInfo(ctl2, testTI, TKIND_DISPATCH, &cti);
4785 ok_ole_success(hr, ICreateTypeLib2_CreateTypeInfo);
4787 hr = ICreateTypeInfo_QueryInterface(cti, &IID_ITypeInfo2, (void**)&ti2);
4788 ok_ole_success(hr, ICreateTypeInfo2_QueryInterface);
4790 tl = NULL;
4791 Index = 888;
4792 hr = ITypeInfo2_GetContainingTypeLib(ti2, &tl, &Index);
4793 ok_ole_success(hr, ITypeInfo2_GetContainingTypeLib);
4794 ok(tl != NULL, "ITypeInfo2_GetContainingTypeLib returned empty TypeLib\n");
4795 ok(Index == 0, "ITypeInfo2_GetContainingTypeLib returned Index = %u, expected 0\n", Index);
4796 if(tl) ITypeLib_Release(tl);
4798 tl = NULL;
4799 hr = ITypeInfo2_GetContainingTypeLib(ti2, &tl, NULL);
4800 ok_ole_success(hr, ITypeInfo2_GetContainingTypeLib);
4801 ok(tl != NULL, "ITypeInfo2_GetContainingTypeLib returned empty TypeLib\n");
4802 if(tl) ITypeLib_Release(tl);
4804 Index = 888;
4805 hr = ITypeInfo2_GetContainingTypeLib(ti2, NULL, &Index);
4806 ok_ole_success(hr, ITypeInfo2_GetContainingTypeLib);
4807 ok(Index == 0, "ITypeInfo2_GetContainingTypeLib returned Index = %u, expected 0\n", Index);
4809 hr = ITypeInfo2_GetContainingTypeLib(ti2, NULL, NULL);
4810 ok_ole_success(hr, ITypeInfo2_GetContainingTypeLib);
4812 ITypeInfo2_Release(ti2);
4813 ICreateTypeInfo_Release(cti);
4814 ICreateTypeLib2_Release(ctl2);
4817 static void create_manifest_file(const char *filename, const char *manifest)
4819 HANDLE file;
4820 DWORD size;
4822 file = CreateFileA(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
4823 FILE_ATTRIBUTE_NORMAL, NULL);
4824 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
4825 WriteFile(file, manifest, strlen(manifest), &size, NULL);
4826 CloseHandle(file);
4829 static HANDLE create_actctx(const char *file)
4831 WCHAR path[MAX_PATH];
4832 ACTCTXW actctx;
4833 HANDLE handle;
4835 MultiByteToWideChar(CP_ACP, 0, file, -1, path, MAX_PATH);
4836 memset(&actctx, 0, sizeof(ACTCTXW));
4837 actctx.cbSize = sizeof(ACTCTXW);
4838 actctx.lpSource = path;
4840 handle = pCreateActCtxW(&actctx);
4841 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
4843 ok(actctx.cbSize == sizeof(actctx), "actctx.cbSize=%d\n", actctx.cbSize);
4844 ok(actctx.dwFlags == 0, "actctx.dwFlags=%d\n", actctx.dwFlags);
4845 ok(actctx.lpSource == path, "actctx.lpSource=%p\n", actctx.lpSource);
4846 ok(actctx.wProcessorArchitecture == 0, "actctx.wProcessorArchitecture=%d\n", actctx.wProcessorArchitecture);
4847 ok(actctx.wLangId == 0, "actctx.wLangId=%d\n", actctx.wLangId);
4848 ok(actctx.lpAssemblyDirectory == NULL, "actctx.lpAssemblyDirectory=%p\n", actctx.lpAssemblyDirectory);
4849 ok(actctx.lpResourceName == NULL, "actctx.lpResourceName=%p\n", actctx.lpResourceName);
4850 ok(actctx.lpApplicationName == NULL, "actctx.lpApplicationName=%p\n",
4851 actctx.lpApplicationName);
4852 ok(actctx.hModule == NULL, "actctx.hModule=%p\n", actctx.hModule);
4854 return handle;
4857 static const char manifest_dep[] =
4858 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
4859 "<assemblyIdentity version=\"1.2.3.4\" name=\"testdep\" type=\"win32\" processorArchitecture=\"" ARCH "\"/>"
4860 "<file name=\"test_actctx_tlb.tlb\">"
4861 " <typelib tlbid=\"{d96d8a3e-78b6-4c8d-8f27-059db959be8a}\" version=\"2.7\" helpdir=\"\" resourceid=\"409\""
4862 " flags=\"Restricted,cONTROL\""
4863 " />"
4864 "</file>"
4865 "<file name=\"test_actctx_tlb2.tlb\">"
4866 " <typelib tlbid=\"{a2cfdbd3-2bbf-4b1c-a414-5a5904e634c9}\" version=\"2.0\" helpdir=\"\" resourceid=\"409\""
4867 " flags=\"RESTRICTED,CONTROL\""
4868 " />"
4869 "</file>"
4870 "</assembly>";
4872 static const char manifest_main[] =
4873 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
4874 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\" />"
4875 "<dependency>"
4876 " <dependentAssembly>"
4877 " <assemblyIdentity type=\"win32\" name=\"testdep\" version=\"1.2.3.4\" processorArchitecture=\"" ARCH "\" />"
4878 " </dependentAssembly>"
4879 "</dependency>"
4880 "</assembly>";
4882 static void test_LoadRegTypeLib(void)
4884 LCID lcid_en = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
4885 LCID lcid_ru = MAKELCID(MAKELANGID(LANG_RUSSIAN, SUBLANG_NEUTRAL), SORT_DEFAULT);
4886 ULONG_PTR cookie;
4887 TLIBATTR *attr;
4888 HANDLE handle;
4889 ITypeLib *tl;
4890 HRESULT hr;
4891 BSTR path;
4892 BOOL ret;
4894 if (!pActivateActCtx)
4896 win_skip("Activation contexts not supported, skipping LoadRegTypeLib tests\n");
4897 return;
4900 create_manifest_file("testdep.manifest", manifest_dep);
4901 create_manifest_file("main.manifest", manifest_main);
4903 handle = create_actctx("main.manifest");
4904 DeleteFileA("testdep.manifest");
4905 DeleteFileA("main.manifest");
4907 /* create typelib file */
4908 write_typelib(1, "test_actctx_tlb.tlb");
4909 write_typelib(3, "test_actctx_tlb2.tlb");
4911 hr = LoadRegTypeLib(&LIBID_TestTypelib, 1, 0, LOCALE_NEUTRAL, &tl);
4912 ok(hr == TYPE_E_LIBNOTREGISTERED, "got 0x%08x\n", hr);
4914 hr = LoadRegTypeLib(&LIBID_register_test, 1, 0, LOCALE_NEUTRAL, &tl);
4915 ok(hr == TYPE_E_LIBNOTREGISTERED, "got 0x%08x\n", hr);
4917 hr = QueryPathOfRegTypeLib(&LIBID_TestTypelib, 2, 0, LOCALE_NEUTRAL, &path);
4918 ok(hr == TYPE_E_LIBNOTREGISTERED, "got 0x%08x\n", hr);
4920 ret = pActivateActCtx(handle, &cookie);
4921 ok(ret, "ActivateActCtx failed: %u\n", GetLastError());
4923 path = NULL;
4924 hr = QueryPathOfRegTypeLib(&LIBID_TestTypelib, 2, 0, LOCALE_NEUTRAL, &path);
4925 ok(hr == S_OK, "got 0x%08x\n", hr);
4926 SysFreeString(path);
4928 path = NULL;
4929 hr = QueryPathOfRegTypeLib(&LIBID_TestTypelib, 2, 0, lcid_en, &path);
4930 ok(hr == S_OK, "got 0x%08x\n", hr);
4931 SysFreeString(path);
4933 path = NULL;
4934 hr = QueryPathOfRegTypeLib(&LIBID_TestTypelib, 2, 0, lcid_ru, &path);
4935 ok(hr == S_OK, "got 0x%08x\n", hr);
4936 SysFreeString(path);
4938 hr = QueryPathOfRegTypeLib(&LIBID_TestTypelib, 2, 8, LOCALE_NEUTRAL, &path);
4939 ok(hr == TYPE_E_LIBNOTREGISTERED || broken(hr == S_OK) /* winxp */, "got 0x%08x\n", hr);
4941 path = NULL;
4942 hr = QueryPathOfRegTypeLib(&LIBID_TestTypelib, 2, 7, LOCALE_NEUTRAL, &path);
4943 ok(hr == S_OK, "got 0x%08x\n", hr);
4944 SysFreeString(path);
4946 path = NULL;
4947 hr = QueryPathOfRegTypeLib(&LIBID_TestTypelib, 1, 0, LOCALE_NEUTRAL, &path);
4948 ok(hr == TYPE_E_LIBNOTREGISTERED || broken(hr == S_OK) /* winxp */, "got 0x%08x\n", hr);
4949 SysFreeString(path);
4951 /* manifest version is 2.0, actual is 1.0 */
4952 hr = LoadRegTypeLib(&LIBID_register_test, 1, 0, LOCALE_NEUTRAL, &tl);
4953 ok(hr == TYPE_E_LIBNOTREGISTERED || broken(hr == S_OK) /* winxp */, "got 0x%08x\n", hr);
4954 if (hr == S_OK) ITypeLib_Release(tl);
4956 hr = LoadRegTypeLib(&LIBID_register_test, 2, 0, LOCALE_NEUTRAL, &tl);
4957 ok(hr == TYPE_E_LIBNOTREGISTERED, "got 0x%08x\n", hr);
4959 /* manifest version is 2.7, actual is 2.5 */
4960 hr = LoadRegTypeLib(&LIBID_TestTypelib, 2, 0, LOCALE_NEUTRAL, &tl);
4961 ok(hr == S_OK, "got 0x%08x\n", hr);
4962 if (hr == S_OK) ITypeLib_Release(tl);
4964 hr = LoadRegTypeLib(&LIBID_TestTypelib, 2, 1, LOCALE_NEUTRAL, &tl);
4965 ok(hr == S_OK, "got 0x%08x\n", hr);
4966 if (hr == S_OK) ITypeLib_Release(tl);
4968 hr = LoadRegTypeLib(&LIBID_TestTypelib, 2, 0, lcid_en, &tl);
4969 ok(hr == S_OK, "got 0x%08x\n", hr);
4970 if (hr == S_OK) ITypeLib_Release(tl);
4972 hr = LoadRegTypeLib(&LIBID_TestTypelib, 2, 0, lcid_ru, &tl);
4973 ok(hr == S_OK, "got 0x%08x\n", hr);
4974 if (hr == S_OK) ITypeLib_Release(tl);
4976 hr = LoadRegTypeLib(&LIBID_TestTypelib, 2, 7, LOCALE_NEUTRAL, &tl);
4977 ok(hr == TYPE_E_LIBNOTREGISTERED, "got 0x%08x\n", hr);
4979 hr = LoadRegTypeLib(&LIBID_TestTypelib, 2, 5, LOCALE_NEUTRAL, &tl);
4980 ok(hr == S_OK, "got 0x%08x\n", hr);
4982 hr = ITypeLib_GetLibAttr(tl, &attr);
4983 ok(hr == S_OK, "got 0x%08x\n", hr);
4985 ok(attr->lcid == 0, "got %x\n", attr->lcid);
4986 ok(attr->wMajorVerNum == 2, "got %d\n", attr->wMajorVerNum);
4987 ok(attr->wMinorVerNum == 5, "got %d\n", attr->wMinorVerNum);
4988 ok(attr->wLibFlags == LIBFLAG_FHASDISKIMAGE, "got %x\n", attr->wLibFlags);
4990 ITypeLib_ReleaseTLibAttr(tl, attr);
4991 ITypeLib_Release(tl);
4993 hr = LoadRegTypeLib(&LIBID_TestTypelib, 1, 7, LOCALE_NEUTRAL, &tl);
4994 ok(hr == TYPE_E_LIBNOTREGISTERED, "got 0x%08x\n", hr);
4996 DeleteFileA("test_actctx_tlb.tlb");
4997 DeleteFileA("test_actctx_tlb2.tlb");
4999 ret = pDeactivateActCtx(0, cookie);
5000 ok(ret, "DeactivateActCtx failed: %u\n", GetLastError());
5002 pReleaseActCtx(handle);
5005 #define AUX_HREF 1
5006 #define AUX_TDESC 2
5007 #define AUX_ADESC 3
5008 static struct _TDATest {
5009 VARTYPE vt;
5010 ULONG size; /* -1 == typelib ptr size */
5011 WORD align;
5012 WORD align3264; /* for 32-bit typelibs loaded in 64-bit mode */
5013 DWORD aux;
5014 TYPEDESC tdesc;
5015 ARRAYDESC adesc;
5016 } TDATests[] = {
5017 { VT_I2, 2, 2, 2 },
5018 { VT_I4, 4, 4, 4 },
5019 { VT_R4, 4, 4, 4 },
5020 { VT_R8, 8, 4, 8 },
5021 { VT_CY, 8, 4, 8 },
5022 { VT_DATE, 8, 4, 8 },
5023 { VT_BSTR, -1, 4, 8 },
5024 { VT_DISPATCH, -1, 4, 8 },
5025 { VT_ERROR, 4, 4, 4 },
5026 { VT_BOOL, 2, 2, 2 },
5027 { VT_VARIANT, 0 /* see code below */, 4, 8 },
5028 { VT_UNKNOWN, -1, 4, 8 },
5029 { VT_DECIMAL, 16, 4, 8 },
5030 { VT_I1, 1, 1, 1 },
5031 { VT_UI1, 1, 1, 1 },
5032 { VT_UI2, 2, 2, 2 },
5033 { VT_UI4, 4, 4, 4 },
5034 { VT_I8, 8, 4, 8 },
5035 { VT_UI8, 8, 4, 8 },
5036 { VT_INT, 4, 4, 4 },
5037 { VT_UINT, 4, 4, 4 },
5038 { VT_VOID, 0, 0, 0 },
5039 { VT_HRESULT, 4, 4, 4 },
5040 { VT_PTR, -1, 4, 8, AUX_TDESC, { { 0 }, VT_INT } },
5041 { VT_SAFEARRAY, -1, 4, 8, AUX_TDESC, { { 0 }, VT_INT } },
5042 { VT_CARRAY, 16 /* == 4 * sizeof(int) */, 4, 4, AUX_ADESC, { { 0 } }, { { { 0 }, VT_INT }, 1, { { 4, 0 } } } },
5043 { VT_USERDEFINED, 0, 0, 0, AUX_HREF },
5044 { VT_LPSTR, -1, 4, 8 },
5045 { VT_LPWSTR, -1, 4, 8 },
5046 { 0 }
5049 static void testTDA(ITypeLib *tl, struct _TDATest *TDATest,
5050 ULONG ptr_size, HREFTYPE hreftype, ULONG href_cbSizeInstance,
5051 WORD href_cbAlignment, BOOL create)
5053 TYPEDESC tdesc;
5054 WCHAR nameW[32];
5055 ITypeInfo *ti;
5056 ICreateTypeInfo *cti;
5057 ICreateTypeLib2 *ctl;
5058 ULONG size;
5059 WORD alignment;
5060 TYPEATTR *typeattr;
5061 HRESULT hr;
5063 static const WCHAR name_fmtW[] = {'a','l','i','a','s','%','0','2','u',0};
5065 wsprintfW(nameW, name_fmtW, TDATest->vt);
5067 if(create){
5068 hr = ITypeLib_QueryInterface(tl, &IID_ICreateTypeLib2, (void**)&ctl);
5069 ok(hr == S_OK, "got %08x\n", hr);
5071 hr = ICreateTypeLib2_CreateTypeInfo(ctl, nameW, TKIND_ALIAS, &cti);
5072 ok(hr == S_OK, "got %08x\n", hr);
5074 tdesc.vt = TDATest->vt;
5075 if(TDATest->aux == AUX_TDESC)
5076 U(tdesc).lptdesc = &TDATest->tdesc;
5077 else if(TDATest->aux == AUX_ADESC)
5078 U(tdesc).lpadesc = &TDATest->adesc;
5079 else if(TDATest->aux == AUX_HREF)
5080 U(tdesc).hreftype = hreftype;
5082 hr = ICreateTypeInfo_SetTypeDescAlias(cti, &tdesc);
5083 ok(hr == S_OK, "for VT %u, got %08x\n", TDATest->vt, hr);
5085 hr = ICreateTypeInfo_QueryInterface(cti, &IID_ITypeInfo, (void**)&ti);
5086 ok(hr == S_OK, "got %08x\n", hr);
5088 ICreateTypeInfo_Release(cti);
5089 ICreateTypeLib2_Release(ctl);
5090 }else{
5091 USHORT found = 1;
5092 MEMBERID memid;
5094 hr = ITypeLib_FindName(tl, nameW, 0, &ti, &memid, &found);
5095 ok(hr == S_OK, "for VT %u, got %08x\n", TDATest->vt, hr);
5098 hr = ITypeInfo_GetTypeAttr(ti, &typeattr);
5099 ok(hr == S_OK, "got %08x\n", hr);
5101 if(TDATest->aux == AUX_HREF){
5102 size = href_cbSizeInstance;
5103 alignment = href_cbAlignment;
5104 }else{
5105 size = TDATest->size;
5106 if(size == -1){
5107 if(create)
5108 size = ptr_size;
5109 else
5110 size = sizeof(void*);
5111 }else if(TDATest->vt == VT_VARIANT){
5112 if(create){
5113 size = sizeof(VARIANT);
5114 #ifdef _WIN64
5115 if(ptr_size != sizeof(void*))
5116 size -= 8; /* 32-bit variant is 4 bytes smaller than 64-bit variant */
5117 #endif
5118 }else
5119 size = sizeof(VARIANT);
5121 alignment = TDATest->align;
5122 #ifdef _WIN64
5123 if(!create && ptr_size != sizeof(void*))
5124 alignment = TDATest->align3264;
5125 #endif
5128 ok(typeattr->cbSizeInstance == size ||
5129 broken(TDATest->vt == VT_VARIANT && ptr_size != sizeof(void*) && typeattr->cbSizeInstance == sizeof(VARIANT)) /* winxp64 */,
5130 "got wrong size for VT %u: 0x%x\n", TDATest->vt, typeattr->cbSizeInstance);
5131 ok(typeattr->cbAlignment == alignment, "got wrong alignment for VT %u: 0x%x\n", TDATest->vt, typeattr->cbAlignment);
5132 ok(typeattr->tdescAlias.vt == TDATest->vt, "got wrong VT for VT %u: 0x%x\n", TDATest->vt, typeattr->tdescAlias.vt);
5134 switch(TDATest->aux){
5135 case AUX_HREF:
5136 ok(U(typeattr->tdescAlias).hreftype == hreftype, "got wrong hreftype for VT %u: 0x%x\n", TDATest->vt, U(typeattr->tdescAlias).hreftype);
5137 break;
5138 case AUX_TDESC:
5139 ok(U(typeattr->tdescAlias).lptdesc->vt == TDATest->tdesc.vt, "got wrong typedesc VT for VT %u: 0x%x\n", TDATest->vt, U(typeattr->tdescAlias).lptdesc->vt);
5140 break;
5141 case AUX_ADESC:
5142 ok(U(typeattr->tdescAlias).lpadesc->tdescElem.vt == TDATest->adesc.tdescElem.vt, "got wrong arraydesc element VT for VT %u: 0x%x\n", TDATest->vt, U(typeattr->tdescAlias).lpadesc->tdescElem.vt);
5143 ok(U(typeattr->tdescAlias).lpadesc->cDims == TDATest->adesc.cDims, "got wrong arraydesc dimension count for VT %u: 0x%x\n", TDATest->vt, U(typeattr->tdescAlias).lpadesc->cDims);
5144 ok(U(typeattr->tdescAlias).lpadesc->rgbounds[0].cElements == TDATest->adesc.rgbounds[0].cElements, "got wrong arraydesc element count for VT %u: 0x%x\n", TDATest->vt, U(typeattr->tdescAlias).lpadesc->rgbounds[0].cElements);
5145 ok(U(typeattr->tdescAlias).lpadesc->rgbounds[0].lLbound == TDATest->adesc.rgbounds[0].lLbound, "got wrong arraydesc lower bound for VT %u: 0x%x\n", TDATest->vt, U(typeattr->tdescAlias).lpadesc->rgbounds[0].lLbound);
5146 break;
5149 ITypeInfo_ReleaseTypeAttr(ti, typeattr);
5150 ITypeInfo_Release(ti);
5153 static void test_SetTypeDescAlias(SYSKIND kind)
5155 CHAR filenameA[MAX_PATH];
5156 WCHAR filenameW[MAX_PATH];
5157 ITypeLib *tl;
5158 ICreateTypeLib2 *ctl;
5159 ITypeInfo *ti;
5160 ICreateTypeInfo *cti;
5161 HREFTYPE hreftype;
5162 TYPEATTR *typeattr;
5163 ULONG href_cbSizeInstance, i;
5164 WORD href_cbAlignment, ptr_size;
5165 HRESULT hr;
5167 static OLECHAR interfaceW[] = {'i','n','t','e','r','f','a','c','e',0};
5169 switch(kind){
5170 case SYS_WIN32:
5171 trace("testing SYS_WIN32\n");
5172 ptr_size = 4;
5173 break;
5174 case SYS_WIN64:
5175 trace("testing SYS_WIN64\n");
5176 ptr_size = 8;
5177 break;
5178 default:
5179 return;
5182 GetTempFileNameA(".", "tlb", 0, filenameA);
5183 MultiByteToWideChar(CP_ACP, 0, filenameA, -1, filenameW, MAX_PATH);
5185 hr = CreateTypeLib2(kind, filenameW, &ctl);
5186 ok(hr == S_OK, "got %08x\n", hr);
5188 hr = ICreateTypeLib2_CreateTypeInfo(ctl, interfaceW, TKIND_INTERFACE, &cti);
5189 ok(hr == S_OK, "got %08x\n", hr);
5191 hr = ICreateTypeInfo_QueryInterface(cti, &IID_ITypeInfo, (void**)&ti);
5192 ok(hr == S_OK, "got %08x\n", hr);
5194 hr = ICreateTypeInfo_AddRefTypeInfo(cti, ti, &hreftype);
5195 ok(hr == S_OK, "got %08x\n", hr);
5197 hr = ITypeInfo_GetTypeAttr(ti, &typeattr);
5198 ok(hr == S_OK, "got %08x\n", hr);
5200 href_cbSizeInstance = typeattr->cbSizeInstance;
5201 href_cbAlignment = typeattr->cbAlignment;
5203 ITypeInfo_ReleaseTypeAttr(ti, typeattr);
5205 ITypeInfo_Release(ti);
5206 ICreateTypeInfo_Release(cti);
5208 hr = ICreateTypeLib2_QueryInterface(ctl, &IID_ITypeLib, (void**)&tl);
5209 ok(hr == S_OK, "got %08x\n", hr);
5211 for(i = 0; TDATests[i].vt; ++i)
5212 testTDA(tl, &TDATests[i], ptr_size, hreftype, href_cbSizeInstance, href_cbAlignment, TRUE);
5214 hr = ICreateTypeLib2_SaveAllChanges(ctl);
5215 ok(hr == S_OK, "got %08x\n", hr);
5217 ITypeLib_Release(tl);
5218 ok(0 == ICreateTypeLib2_Release(ctl), "typelib should have been released\n");
5220 trace("after save...\n");
5222 hr = LoadTypeLibEx(filenameW, REGKIND_NONE, &tl);
5223 ok(hr == S_OK, "got %08x\n", hr);
5225 hr = ITypeLib_GetTypeInfo(tl, 0, &ti);
5226 ok(hr == S_OK, "got %08x\n", hr);
5228 hr = ITypeInfo_GetTypeAttr(ti, &typeattr);
5229 ok(hr == S_OK, "got %08x\n", hr);
5231 href_cbSizeInstance = typeattr->cbSizeInstance;
5232 href_cbAlignment = typeattr->cbAlignment;
5234 ITypeInfo_ReleaseTypeAttr(ti, typeattr);
5235 ITypeInfo_Release(ti);
5237 for(i = 0; TDATests[i].vt; ++i)
5238 testTDA(tl, &TDATests[i], ptr_size, hreftype, href_cbSizeInstance, href_cbAlignment, FALSE);
5240 ok(0 == ITypeLib_Release(tl), "typelib should have been released\n");
5242 DeleteFileA(filenameA);
5245 static void test_GetLibAttr(void)
5247 ULONG ref1, ref2;
5248 TLIBATTR *attr;
5249 ITypeLib *tl;
5250 HRESULT hr;
5252 hr = LoadTypeLib(wszStdOle2, &tl);
5253 ok(hr == S_OK, "got 0x%08x\n", hr);
5255 ref1 = ITypeLib_AddRef(tl);
5256 ITypeLib_Release(tl);
5258 hr = ITypeLib_GetLibAttr(tl, &attr);
5259 ok(hr == S_OK, "got 0x%08x\n", hr);
5261 ref2 = ITypeLib_AddRef(tl);
5262 ITypeLib_Release(tl);
5263 ok(ref2 == ref1, "got %d, %d\n", ref2, ref1);
5265 ITypeLib_ReleaseTLibAttr(tl, attr);
5266 ITypeLib_Release(tl);
5269 static HRESULT WINAPI uk_QueryInterface(IUnknown *obj, REFIID iid, void **out)
5271 return E_NOINTERFACE;
5274 static ULONG WINAPI uk_AddRef(IUnknown *obj)
5276 return 2;
5279 static ULONG WINAPI uk_Release(IUnknown *obj)
5281 return 1;
5284 IUnknownVtbl vt = {
5285 uk_QueryInterface,
5286 uk_AddRef,
5287 uk_Release,
5290 IUnknown uk = {&vt};
5292 static void test_stub(void)
5294 HRESULT hr;
5295 CLSID clsid;
5296 IPSFactoryBuffer *factory;
5297 IRpcStubBuffer *base_stub;
5298 ITypeLib *stdole;
5299 ICreateTypeLib2 *ctl;
5300 ICreateTypeInfo *cti;
5301 ITypeLib *tl;
5302 ITypeInfo *unk, *ti;
5303 HREFTYPE href;
5304 char filenameA[MAX_PATH];
5305 WCHAR filenameW[MAX_PATH];
5306 HKEY hkey;
5307 LONG lr;
5309 static const GUID libguid = {0x3b9ff02e,0x9675,0x4861,{0xb7,0x81,0xce,0xae,0xa4,0x78,0x2a,0xcc}};
5310 static const GUID interfaceguid = {0x3b9ff02f,0x9675,0x4861,{0xb7,0x81,0xce,0xae,0xa4,0x78,0x2a,0xcc}};
5311 static const GUID coclassguid = {0x3b9ff030,0x9675,0x4861,{0xb7,0x81,0xce,0xae,0xa4,0x78,0x2a,0xcc}};
5312 static OLECHAR interfaceW[] = {'i','n','t','e','r','f','a','c','e',0};
5313 static OLECHAR classW[] = {'c','l','a','s','s',0};
5315 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
5317 hr = LoadTypeLib(wszStdOle2, &stdole);
5318 ok(hr == S_OK, "got %08x\n", hr);
5320 hr = ITypeLib_GetTypeInfoOfGuid(stdole, &IID_IUnknown, &unk);
5321 ok(hr == S_OK, "got %08x\n", hr);
5323 GetTempFileNameA(".", "tlb", 0, filenameA);
5324 MultiByteToWideChar(CP_ACP, 0, filenameA, -1, filenameW, MAX_PATH);
5326 hr = CreateTypeLib2(SYS_WIN32, filenameW, &ctl);
5327 ok(hr == S_OK, "got %08x\n", hr);
5329 hr = ICreateTypeLib2_SetGuid(ctl, &libguid);
5330 ok(hr == S_OK, "got %08x\n", hr);
5332 hr = ICreateTypeLib2_SetLcid(ctl, LOCALE_NEUTRAL);
5333 ok(hr == S_OK, "got %08x\n", hr);
5335 hr = ICreateTypeLib2_CreateTypeInfo(ctl, interfaceW, TKIND_INTERFACE, &cti);
5336 ok(hr == S_OK, "got %08x\n", hr);
5338 hr = ICreateTypeInfo_SetGuid(cti, &interfaceguid);
5339 ok(hr == S_OK, "got %08x\n", hr);
5341 hr = ICreateTypeInfo_SetTypeFlags(cti, TYPEFLAG_FOLEAUTOMATION);
5342 ok(hr == S_OK, "got %08x\n", hr);
5344 hr = ICreateTypeInfo_AddRefTypeInfo(cti, unk, &href);
5345 ok(hr == S_OK, "got %08x\n", hr);
5347 hr = ICreateTypeInfo_AddImplType(cti, 0, href);
5348 ok(hr == S_OK, "got %08x\n", hr);
5350 hr = ICreateTypeInfo_QueryInterface(cti, &IID_ITypeInfo, (void**)&ti);
5351 ok(hr == S_OK, "got %08x\n", hr);
5353 ICreateTypeInfo_Release(cti);
5354 ITypeInfo_Release(unk);
5355 ITypeLib_Release(stdole);
5357 hr = ICreateTypeLib2_CreateTypeInfo(ctl, classW, TKIND_COCLASS, &cti);
5358 ok(hr == S_OK, "got %08x\n", hr);
5360 hr = ICreateTypeInfo_SetGuid(cti, &coclassguid);
5361 ok(hr == S_OK, "got %08x\n", hr);
5363 hr = ICreateTypeInfo_AddRefTypeInfo(cti, ti, &href);
5364 ok(hr == S_OK, "got %08x\n", hr);
5366 hr = ICreateTypeInfo_AddImplType(cti, 0, href);
5367 ok(hr == S_OK, "got %08x\n", hr);
5369 ITypeInfo_Release(ti);
5370 ICreateTypeInfo_Release(cti);
5372 hr = ICreateTypeLib2_SaveAllChanges(ctl);
5373 ok(hr == S_OK, "got %08x\n", hr);
5375 hr = ICreateTypeLib2_QueryInterface(ctl, &IID_ITypeLib, (void**)&tl);
5376 ok(hr == S_OK, "got %08x\n", hr);
5378 hr = RegisterTypeLib(tl, filenameW, NULL);
5379 if (hr == TYPE_E_REGISTRYACCESS)
5381 win_skip("Insufficient privileges to register typelib in the registry\n");
5382 ITypeLib_Release(tl);
5383 DeleteFileW(filenameW);
5384 CoUninitialize();
5385 return;
5387 ok(hr == S_OK, "got %08x\n", hr);
5389 ITypeLib_Release(tl);
5390 ok(0 == ICreateTypeLib2_Release(ctl), "Typelib still has references\n");
5392 /* SYS_WIN32 typelibs should be registered only as 32-bit */
5393 lr = RegOpenKeyExA(HKEY_CLASSES_ROOT, "TypeLib\\{3b9ff02e-9675-4861-b781-ceaea4782acc}\\0.0\\0\\win64", 0, KEY_READ, &hkey);
5394 ok(lr == ERROR_FILE_NOT_FOUND, "got wrong return code: %u\n", lr);
5396 lr = RegOpenKeyExA(HKEY_CLASSES_ROOT, "TypeLib\\{3b9ff02e-9675-4861-b781-ceaea4782acc}\\0.0\\0\\win32", 0, KEY_READ, &hkey);
5397 ok(lr == ERROR_SUCCESS, "got wrong return code: %u\n", lr);
5398 RegCloseKey(hkey);
5400 hr = CoGetPSClsid(&interfaceguid, &clsid);
5401 ok(hr == S_OK, "got: %x\n", hr);
5403 hr = CoGetClassObject(&clsid, CLSCTX_INPROC_SERVER, NULL,
5404 &IID_IPSFactoryBuffer, (void **)&factory);
5405 ok(hr == S_OK, "got: %x\n", hr);
5407 hr = IPSFactoryBuffer_CreateStub(factory, &interfaceguid, &uk, &base_stub);
5408 ok(hr == S_OK, "got: %x\n", hr);
5410 IPSFactoryBuffer_Release(factory);
5412 UnRegisterTypeLib(&libguid, 0, 0, 0, SYS_WIN32);
5413 DeleteFileW(filenameW);
5415 CoUninitialize();
5418 START_TEST(typelib)
5420 const char *filename;
5422 init_function_pointers();
5424 ref_count_test(wszStdOle2);
5425 test_TypeComp();
5426 test_CreateDispTypeInfo();
5427 test_TypeInfo();
5428 test_DispCallFunc();
5429 test_QueryPathOfRegTypeLib(32);
5430 if(sizeof(void*) == 8){
5431 test_QueryPathOfRegTypeLib(64);
5432 test_CreateTypeLib(SYS_WIN64);
5433 test_SetTypeDescAlias(SYS_WIN64);
5435 test_CreateTypeLib(SYS_WIN32);
5436 test_SetTypeDescAlias(SYS_WIN32);
5437 test_inheritance();
5438 test_SetVarHelpContext();
5439 test_SetFuncAndParamNames();
5440 test_SetDocString();
5441 test_FindName();
5443 if ((filename = create_test_typelib(2)))
5445 test_dump_typelib( filename );
5446 DeleteFileA( filename );
5449 test_register_typelib(TRUE);
5450 test_register_typelib(FALSE);
5451 test_create_typelibs();
5452 test_LoadTypeLib();
5453 test_TypeInfo2_GetContainingTypeLib();
5454 test_LoadRegTypeLib();
5455 test_GetLibAttr();
5456 test_stub();