2 * Copyright (C) 2005-2006 Robert Shearman for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include <wine/test.h>
30 #include "tmarshal_dispids.h"
32 #define ok_ole_success(hr, func) ok(hr == S_OK, #func " failed with error 0x%08lx\n", (unsigned long int)hr)
34 /* Debugging functions from wine/libs/wine/debug.c */
36 /* allocate some tmp string space */
37 /* FIXME: this is not 100% thread-safe */
38 static char *get_tmp_space( int size )
40 static char *list[32];
45 idx = ++pos % (sizeof(list)/sizeof(list[0]));
46 if ((ret = realloc( list[idx], size ))) list[idx] = ret;
50 /* default implementation of wine_dbgstr_wn */
51 static const char *default_dbgstr_wn( const WCHAR *str, int n )
57 if (!str) return "(null)";
58 res = get_tmp_space( 6 );
59 sprintf( res, "#%04x", LOWORD(str) );
62 if (n == -1) n = lstrlenW(str);
64 else if (n > 200) n = 200;
65 dst = res = get_tmp_space( n * 5 + 7 );
73 case '\n': *dst++ = '\\'; *dst++ = 'n'; break;
74 case '\r': *dst++ = '\\'; *dst++ = 'r'; break;
75 case '\t': *dst++ = '\\'; *dst++ = 't'; break;
76 case '"': *dst++ = '\\'; *dst++ = '"'; break;
77 case '\\': *dst++ = '\\'; *dst++ = '\\'; break;
79 if (c >= ' ' && c <= 126)
84 sprintf(dst,"%04x",c);
100 const char *wine_dbgstr_wn( const WCHAR *s, int n )
102 return default_dbgstr_wn(s, n);
105 const char *wine_dbgstr_w( const WCHAR *s )
107 return default_dbgstr_wn( s, -1 );
111 #define RELEASEMARSHALDATA WM_USER
113 struct host_object_data
118 MSHLFLAGS marshal_flags;
119 HANDLE marshal_event;
120 IMessageFilter *filter;
123 static DWORD CALLBACK host_object_proc(LPVOID p)
125 struct host_object_data *data = (struct host_object_data *)p;
129 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
133 IMessageFilter * prev_filter = NULL;
134 hr = CoRegisterMessageFilter(data->filter, &prev_filter);
135 if (prev_filter) IMessageFilter_Release(prev_filter);
136 ok_ole_success(hr, CoRegisterMessageFilter);
139 hr = CoMarshalInterface(data->stream, &data->iid, data->object, MSHCTX_INPROC, NULL, data->marshal_flags);
140 ok_ole_success(hr, CoMarshalInterface);
142 /* force the message queue to be created before signaling parent thread */
143 PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
145 SetEvent(data->marshal_event);
147 while (GetMessage(&msg, NULL, 0, 0))
149 if (msg.hwnd == NULL && msg.message == RELEASEMARSHALDATA)
151 trace("releasing marshal data\n");
152 CoReleaseMarshalData(data->stream);
153 SetEvent((HANDLE)msg.lParam);
156 DispatchMessage(&msg);
159 HeapFree(GetProcessHeap(), 0, data);
166 static DWORD start_host_object2(IStream *stream, REFIID riid, IUnknown *object, MSHLFLAGS marshal_flags, IMessageFilter *filter, HANDLE *thread)
169 HANDLE marshal_event = CreateEvent(NULL, FALSE, FALSE, NULL);
170 struct host_object_data *data = HeapAlloc(GetProcessHeap(), 0, sizeof(*data));
172 data->stream = stream;
174 data->object = object;
175 data->marshal_flags = marshal_flags;
176 data->marshal_event = marshal_event;
177 data->filter = filter;
179 *thread = CreateThread(NULL, 0, host_object_proc, data, 0, &tid);
181 /* wait for marshaling to complete before returning */
182 WaitForSingleObject(marshal_event, INFINITE);
183 CloseHandle(marshal_event);
188 static DWORD start_host_object(IStream *stream, REFIID riid, IUnknown *object, MSHLFLAGS marshal_flags, HANDLE *thread)
190 return start_host_object2(stream, riid, object, marshal_flags, NULL, thread);
194 /* asks thread to release the marshal data because it has to be done by the
195 * same thread that marshaled the interface in the first place. */
196 static void release_host_object(DWORD tid)
198 HANDLE event = CreateEvent(NULL, FALSE, FALSE, NULL);
199 PostThreadMessage(tid, RELEASEMARSHALDATA, 0, (LPARAM)event);
200 WaitForSingleObject(event, INFINITE);
205 static void end_host_object(DWORD tid, HANDLE thread)
207 BOOL ret = PostThreadMessage(tid, WM_QUIT, 0, 0);
208 ok(ret, "PostThreadMessage failed with error %d\n", GetLastError());
209 /* be careful of races - don't return until hosting thread has terminated */
210 WaitForSingleObject(thread, INFINITE);
214 static ItestDual TestDual, TestDualDisp;
216 static HRESULT WINAPI TestDual_QueryInterface(ItestDual *iface, REFIID riid, void **ppvObject)
218 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDispatch)) {
219 *ppvObject = &TestDualDisp;
221 }else if(IsEqualGUID(riid, &IID_ItestDual)) {
222 *ppvObject = &TestDual;
227 return E_NOINTERFACE;
230 static ULONG WINAPI TestDual_AddRef(ItestDual *iface)
235 static ULONG WINAPI TestDual_Release(ItestDual *iface)
240 static HRESULT WINAPI TestDual_GetTypeInfoCount(ItestDual *iface, UINT *pctinfo)
242 ok(0, "unexpected call\n");
246 static HRESULT WINAPI TestDual_GetTypeInfo(ItestDual *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
248 ok(0, "unexpected call\n");
252 static HRESULT WINAPI TestDual_GetIDsOfNames(ItestDual *iface, REFIID riid, LPOLESTR *rgszNames,
253 UINT cNames, LCID lcid, DISPID *rgDispId)
255 ok(0, "unexpected call\n");
259 static HRESULT WINAPI TestDual_Invoke(ItestDual *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
260 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
263 ok(0, "unexpected call\n");
267 static ItestDualVtbl TestDualVtbl = {
268 TestDual_QueryInterface,
271 TestDual_GetTypeInfoCount,
272 TestDual_GetTypeInfo,
273 TestDual_GetIDsOfNames,
277 static ItestDual TestDual = { &TestDualVtbl };
278 static ItestDual TestDualDisp = { &TestDualVtbl };
280 typedef struct Widget
282 const IWidgetVtbl *lpVtbl;
284 IUnknown *pDispatchUnknown;
287 HRESULT WINAPI Widget_QueryInterface(
289 /* [in] */ REFIID riid,
290 /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject)
292 if (IsEqualIID(riid, &IID_IWidget) || IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDispatch))
294 IWidget_AddRef(iface);
301 return E_NOINTERFACE;
305 ULONG WINAPI Widget_AddRef(
308 Widget *This = (Widget *)iface;
310 return InterlockedIncrement(&This->refs);
313 ULONG WINAPI Widget_Release(
316 Widget *This = (Widget *)iface;
317 ULONG refs = InterlockedDecrement(&This->refs);
320 IUnknown_Release(This->pDispatchUnknown);
321 memset(This, 0xcc, sizeof(*This));
322 HeapFree(GetProcessHeap(), 0, This);
323 trace("Widget destroyed!\n");
329 HRESULT WINAPI Widget_GetTypeInfoCount(
331 /* [out] */ UINT __RPC_FAR *pctinfo)
333 Widget *This = (Widget *)iface;
334 IDispatch *pDispatch;
335 HRESULT hr = IUnknown_QueryInterface(This->pDispatchUnknown, &IID_IDispatch, (void **)&pDispatch);
338 hr = IDispatch_GetTypeInfoCount(pDispatch, pctinfo);
339 IDispatch_Release(pDispatch);
344 HRESULT WINAPI Widget_GetTypeInfo(
345 IWidget __RPC_FAR * iface,
346 /* [in] */ UINT iTInfo,
347 /* [in] */ LCID lcid,
348 /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo)
350 Widget *This = (Widget *)iface;
351 IDispatch *pDispatch;
352 HRESULT hr = IUnknown_QueryInterface(This->pDispatchUnknown, &IID_IDispatch, (void **)&pDispatch);
355 hr = IDispatch_GetTypeInfo(pDispatch, iTInfo, lcid, ppTInfo);
356 IDispatch_Release(pDispatch);
361 HRESULT WINAPI Widget_GetIDsOfNames(
362 IWidget __RPC_FAR * iface,
363 /* [in] */ REFIID riid,
364 /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,
365 /* [in] */ UINT cNames,
366 /* [in] */ LCID lcid,
367 /* [size_is][out] */ DISPID __RPC_FAR *rgDispId)
369 Widget *This = (Widget *)iface;
370 IDispatch *pDispatch;
371 HRESULT hr = IUnknown_QueryInterface(This->pDispatchUnknown, &IID_IDispatch, (void **)&pDispatch);
374 hr = IDispatch_GetIDsOfNames(pDispatch, riid, rgszNames, cNames, lcid, rgDispId);
375 IDispatch_Release(pDispatch);
380 HRESULT WINAPI Widget_Invoke(
381 IWidget __RPC_FAR * iface,
382 /* [in] */ DISPID dispIdMember,
383 /* [in] */ REFIID riid,
384 /* [in] */ LCID lcid,
385 /* [in] */ WORD wFlags,
386 /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,
387 /* [out] */ VARIANT __RPC_FAR *pVarResult,
388 /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
389 /* [out] */ UINT __RPC_FAR *puArgErr)
391 Widget *This = (Widget *)iface;
392 IDispatch *pDispatch;
393 HRESULT hr = IUnknown_QueryInterface(This->pDispatchUnknown, &IID_IDispatch, (void **)&pDispatch);
396 hr = IDispatch_Invoke(pDispatch, dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
397 IDispatch_Release(pDispatch);
402 HRESULT WINAPI Widget_put_Name(
403 IWidget __RPC_FAR * iface,
404 /* [in] */ BSTR name)
406 trace("put_Name(%s)\n", wine_dbgstr_w(name));
410 HRESULT WINAPI Widget_get_Name(
411 IWidget __RPC_FAR * iface,
412 /* [out] */ BSTR __RPC_FAR *name)
414 static const WCHAR szCat[] = { 'C','a','t',0 };
415 trace("get_Name()\n");
416 *name = SysAllocString(szCat);
420 HRESULT WINAPI Widget_DoSomething(
421 IWidget __RPC_FAR * iface,
422 /* [in] */ double number,
423 /* [out] */ BSTR *str1,
424 /* [defaultvalue][in] */ BSTR str2,
425 /* [optional][in] */ VARIANT __RPC_FAR *opt)
427 static const WCHAR szString[] = { 'S','t','r','i','n','g',0 };
428 trace("DoSomething()\n");
430 ok(number == 3.141, "number(%f) != 3.141\n", number);
431 ok(*str2 == '\0', "str2(%s) != \"\"\n", wine_dbgstr_w(str2));
432 ok(V_VT(opt) == VT_ERROR, "V_VT(opt) should be VT_ERROR instead of 0x%x\n", V_VT(opt));
433 ok(V_ERROR(opt) == DISP_E_PARAMNOTFOUND, "V_ERROR(opt) should be DISP_E_PARAMNOTFOUND instead of 0x%08x\n", V_ERROR(opt));
434 *str1 = SysAllocString(szString);
439 HRESULT WINAPI Widget_get_State(
440 IWidget __RPC_FAR * iface,
441 /* [retval][out] */ STATE __RPC_FAR *state)
443 trace("get_State() = STATE_WIDGETIFIED\n");
444 *state = STATE_WIDGETIFIED;
448 HRESULT WINAPI Widget_put_State(
449 IWidget __RPC_FAR * iface,
450 /* [in] */ STATE state)
452 trace("put_State(%d)\n", state);
456 HRESULT WINAPI Widget_Map(
461 trace("Map(%s, %p)\n", wine_dbgstr_w(bstrId), sValue);
462 *sValue = SysAllocString(bstrId);
466 HRESULT WINAPI Widget_SetOleColor(
470 trace("SetOleColor(0x%x)\n", val);
474 HRESULT WINAPI Widget_GetOleColor(
478 trace("GetOleColor() = 0x8000000f\n");
483 HRESULT WINAPI Widget_Clone(
488 return Widget_QueryInterface(iface, &IID_IWidget, (void **)ppVal);
491 HRESULT WINAPI Widget_CloneDispatch(
495 trace("CloneDispatch()\n");
496 return Widget_QueryInterface(iface, &IID_IWidget, (void **)ppVal);
499 HRESULT WINAPI Widget_CloneCoclass(
501 ApplicationObject2 **ppVal)
503 trace("CloneCoclass()\n");
507 HRESULT WINAPI Widget_Value(
508 IWidget __RPC_FAR * iface,
512 trace("Value(%p, %p)\n", value, retval);
513 ok(V_VT(value) == VT_I2, "V_VT(value) was %d instead of VT_I2\n", V_VT(value));
514 ok(V_I2(value) == 1, "V_I2(value) was %d instead of 1\n", V_I2(value));
515 V_VT(retval) = VT_I2;
520 HRESULT WINAPI Widget_Array(
524 trace("Array(%p)\n", values);
528 HRESULT WINAPI Widget_VariantArrayPtr(
532 trace("VariantArrayPtr(%p)\n", values);
536 void WINAPI Widget_Variant(
537 IWidget __RPC_FAR * iface,
540 trace("Variant()\n");
541 ok(V_VT(&var) == VT_CY, "V_VT(&var) was %d\n", V_VT(&var));
542 ok(S(V_CY(&var)).Hi == 0xdababe, "V_CY(&var).Hi was 0x%x\n", S(V_CY(&var)).Hi);
543 ok(S(V_CY(&var)).Lo == 0xdeadbeef, "V_CY(&var).Lo was 0x%x\n", S(V_CY(&var)).Lo);
546 void WINAPI Widget_VarArg(
551 LONG lbound, ubound, i;
555 trace("VarArg(%p)\n", values);
557 hr = SafeArrayGetLBound(values, 1, &lbound);
558 ok(hr == S_OK, "SafeArrayGetLBound failed with %x\n", hr);
559 ok(lbound == 0, "SafeArrayGetLBound returned %d\n", lbound);
561 hr = SafeArrayGetUBound(values, 1, &ubound);
562 ok(hr == S_OK, "SafeArrayGetUBound failed with %x\n", hr);
563 ok(ubound == numexpect-1, "SafeArrayGetUBound returned %d, but expected %d\n", ubound, numexpect-1);
565 hr = SafeArrayAccessData(values, (LPVOID)&data);
566 ok(hr == S_OK, "SafeArrayAccessData failed with %x\n", hr);
568 for (i=0; i<=ubound-lbound; i++)
570 ok(V_VT(&data[i]) == VT_I4, "V_VT(&data[%d]) was %d\n", i, V_VT(&data[i]));
571 ok(V_I4(&data[i]) == i, "V_I4(&data[%d]) was %d\n", i, V_I4(&data[i]));
574 hr = SafeArrayUnaccessData(values);
575 ok(hr == S_OK, "SafeArrayUnaccessData failed with %x\n", hr);
578 HRESULT WINAPI Widget_Error(
579 IWidget __RPC_FAR * iface)
585 HRESULT WINAPI Widget_CloneInterface(
586 IWidget __RPC_FAR * iface,
587 ISomethingFromDispatch **ppVal)
589 trace("CloneInterface()\n");
594 static const struct IWidgetVtbl Widget_VTable =
596 Widget_QueryInterface,
599 Widget_GetTypeInfoCount,
601 Widget_GetIDsOfNames,
612 Widget_CloneDispatch,
616 Widget_VariantArrayPtr,
620 Widget_CloneInterface
623 static HRESULT WINAPI StaticWidget_QueryInterface(IStaticWidget *iface, REFIID riid, void **ppvObject)
625 if (IsEqualIID(riid, &IID_IStaticWidget) || IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDispatch))
627 IStaticWidget_AddRef(iface);
633 return E_NOINTERFACE;
636 static ULONG WINAPI StaticWidget_AddRef(IStaticWidget *iface)
641 static ULONG WINAPI StaticWidget_Release(IStaticWidget *iface)
646 static HRESULT WINAPI StaticWidget_GetTypeInfoCount(IStaticWidget *iface, UINT *pctinfo)
648 ok(0, "unexpected call\n");
652 static HRESULT WINAPI StaticWidget_GetTypeInfo(IStaticWidget *iface, UINT iTInfo, LCID lcid,
655 ok(0, "unexpected call\n");
659 static HRESULT WINAPI StaticWidget_GetIDsOfNames(IStaticWidget *iface, REFIID riid, LPOLESTR *rgszNames,
660 UINT cNames, LCID lcid, DISPID *rgDispId)
662 ok(0, "unexpected call\n");
666 static HRESULT WINAPI StaticWidget_Invoke(IStaticWidget *iface, DISPID dispIdMember, REFIID riid,
667 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
670 ok(0, "unexpected call\n");
674 static HRESULT WINAPI StaticWidget_TestDual(IStaticWidget *iface, ItestDual *p)
676 trace("TestDual()\n");
678 ok(p == &TestDual, "wrong ItestDual\n");
682 static const IStaticWidgetVtbl StaticWidgetVtbl = {
683 StaticWidget_QueryInterface,
685 StaticWidget_Release,
686 StaticWidget_GetTypeInfoCount,
687 StaticWidget_GetTypeInfo,
688 StaticWidget_GetIDsOfNames,
690 StaticWidget_TestDual
693 static IStaticWidget StaticWidget = { &StaticWidgetVtbl };
695 typedef struct KindaEnum
697 const IKindaEnumWidgetVtbl *lpVtbl;
701 static HRESULT register_current_module_typelib(void)
703 WCHAR path[MAX_PATH];
707 GetModuleFileNameW(NULL, path, MAX_PATH);
709 hr = LoadTypeLib(path, &typelib);
712 hr = RegisterTypeLib(typelib, path, NULL);
713 ITypeLib_Release(typelib);
718 static ITypeInfo *get_type_info(REFIID riid)
720 ITypeInfo *pTypeInfo;
724 hr = LoadRegTypeLib(&LIBID_TestTypelib, 1, 0, LOCALE_NEUTRAL, &pTypeLib);
725 ok_ole_success(hr, LoadRegTypeLib);
729 hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, riid, &pTypeInfo);
730 ITypeLib_Release(pTypeLib);
731 ok_ole_success(hr, ITypeLib_GetTypeInfoOfGuid);
738 static IWidget *Widget_Create(void)
741 ITypeInfo *pTypeInfo;
744 pTypeInfo = get_type_info(&IID_IWidget);
748 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
749 This->lpVtbl = &Widget_VTable;
751 This->pDispatchUnknown = NULL;
753 hr = CreateStdDispatch((IUnknown *)&This->lpVtbl, This, pTypeInfo, &This->pDispatchUnknown);
754 ok_ole_success(hr, CreateStdDispatch);
755 ITypeInfo_Release(pTypeInfo);
758 return (IWidget *)&This->lpVtbl;
761 HeapFree(GetProcessHeap(), 0, This);
766 HRESULT WINAPI KindaEnum_QueryInterface(
767 IKindaEnumWidget *iface,
768 /* [in] */ REFIID riid,
769 /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject)
771 if (IsEqualIID(riid, &IID_IKindaEnumWidget) || IsEqualIID(riid, &IID_IUnknown))
773 IKindaEnumWidget_AddRef(iface);
780 return E_NOINTERFACE;
784 ULONG WINAPI KindaEnum_AddRef(
785 IKindaEnumWidget *iface)
787 KindaEnum *This = (KindaEnum *)iface;
789 return InterlockedIncrement(&This->refs);
792 ULONG WINAPI KindaEnum_Release(
793 IKindaEnumWidget *iface)
795 KindaEnum *This = (KindaEnum *)iface;
796 ULONG refs = InterlockedDecrement(&This->refs);
799 memset(This, 0xcc, sizeof(*This));
800 HeapFree(GetProcessHeap(), 0, This);
801 trace("KindaEnumWidget destroyed!\n");
807 HRESULT WINAPI KindaEnum_Next(
808 IKindaEnumWidget *iface,
809 /* [out] */ IWidget __RPC_FAR *__RPC_FAR *widget)
811 *widget = Widget_Create();
815 return E_OUTOFMEMORY;
818 HRESULT WINAPI KindaEnum_Count(
819 IKindaEnumWidget *iface,
820 /* [out] */ unsigned long __RPC_FAR *count)
825 HRESULT WINAPI KindaEnum_Reset(
826 IKindaEnumWidget *iface)
831 HRESULT WINAPI KindaEnum_Clone(
832 IKindaEnumWidget *iface,
833 /* [out] */ IKindaEnumWidget __RPC_FAR *__RPC_FAR *ppenum)
838 static const IKindaEnumWidgetVtbl KindaEnumWidget_VTable =
840 KindaEnum_QueryInterface,
849 static IKindaEnumWidget *KindaEnumWidget_Create(void)
853 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
854 if (!This) return NULL;
855 This->lpVtbl = &KindaEnumWidget_VTable;
857 return (IKindaEnumWidget *)This;
860 static HRESULT WINAPI NonOleAutomation_QueryInterface(INonOleAutomation *iface, REFIID riid, void **ppv)
862 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_INonOleAutomation))
864 *(INonOleAutomation **)ppv = iface;
868 return E_NOINTERFACE;
871 static ULONG WINAPI NonOleAutomation_AddRef(INonOleAutomation *iface)
876 static ULONG WINAPI NonOleAutomation_Release(INonOleAutomation *iface)
881 static BSTR WINAPI NonOleAutomation_BstrRet(INonOleAutomation *iface)
883 static const WCHAR wszTestString[] = {'T','h','i','s',' ','i','s',' ','a',' ','t','e','s','t',' ','s','t','r','i','n','g',0};
884 return SysAllocString(wszTestString);
887 static INonOleAutomationVtbl NonOleAutomation_VTable =
889 NonOleAutomation_QueryInterface,
890 NonOleAutomation_AddRef,
891 NonOleAutomation_Release,
892 NonOleAutomation_BstrRet,
895 static INonOleAutomation NonOleAutomation = { &NonOleAutomation_VTable };
897 static ITypeInfo *NonOleAutomation_GetTypeInfo(void)
900 HRESULT hr = LoadRegTypeLib(&LIBID_TestTypelib, 1, 0, LOCALE_NEUTRAL, &pTypeLib);
901 ok_ole_success(hr, LoadRegTypeLib);
904 ITypeInfo *pTypeInfo;
905 hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, &IID_INonOleAutomation, &pTypeInfo);
906 ok_ole_success(hr, ITypeLib_GetTypeInfoOfGuid);
912 static void test_typelibmarshal(void)
914 static const WCHAR szCat[] = { 'C','a','t',0 };
915 static const WCHAR szTestTest[] = { 'T','e','s','t','T','e','s','t',0 };
916 static WCHAR szSuperman[] = { 'S','u','p','e','r','m','a','n',0 };
918 IKindaEnumWidget *pKEW = KindaEnumWidget_Create();
921 IDispatch *pDispatch;
922 static const LARGE_INTEGER ullZero;
925 DISPID dispidNamed = DISPID_PROPERTYPUT;
926 DISPPARAMS dispparams;
927 VARIANTARG vararg[4];
932 ITypeInfo *pTypeInfo;
934 ok(pKEW != NULL, "Widget creation failed\n");
936 hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
937 ok_ole_success(hr, CreateStreamOnHGlobal);
938 tid = start_host_object(pStream, &IID_IKindaEnumWidget, (IUnknown *)pKEW, MSHLFLAGS_NORMAL, &thread);
939 IKindaEnumWidget_Release(pKEW);
941 IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
942 hr = CoUnmarshalInterface(pStream, &IID_IKindaEnumWidget, (void **)&pKEW);
943 ok_ole_success(hr, CoUnmarshalInterface);
944 IStream_Release(pStream);
946 hr = IKindaEnumWidget_Next(pKEW, &pWidget);
947 ok_ole_success(hr, IKindaEnumWidget_Next);
949 IKindaEnumWidget_Release(pKEW);
951 hr = IWidget_QueryInterface(pWidget, &IID_IDispatch, (void **)&pDispatch);
954 VariantInit(&vararg[0]);
955 dispparams.cNamedArgs = 1;
956 dispparams.rgdispidNamedArgs = &dispidNamed;
957 dispparams.cArgs = 1;
958 dispparams.rgvarg = vararg;
959 VariantInit(&varresult);
960 hr = IDispatch_Invoke(pDispatch, DISPID_TM_NAME, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYPUT, &dispparams, &varresult, &excepinfo, NULL);
961 ok_ole_success(hr, IDispatch_Invoke);
962 ok(excepinfo.wCode == 0x0 && excepinfo.scode == S_OK,
963 "EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
964 excepinfo.wCode, excepinfo.scode);
965 VariantClear(&varresult);
967 /* call put_Name (direct) */
968 bstr = SysAllocString(szSuperman);
969 hr = IWidget_put_Name(pWidget, bstr);
970 ok_ole_success(hr, IWidget_put_Name);
974 dispparams.cNamedArgs = 0;
975 dispparams.rgdispidNamedArgs = NULL;
976 dispparams.cArgs = 0;
977 dispparams.rgvarg = NULL;
978 VariantInit(&varresult);
979 hr = IDispatch_Invoke(pDispatch, DISPID_TM_NAME, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
980 ok_ole_success(hr, IDispatch_Invoke);
981 ok(excepinfo.wCode == 0x0 && excepinfo.scode == S_OK,
982 "EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
983 excepinfo.wCode, excepinfo.scode);
984 trace("Name = %s\n", wine_dbgstr_w(V_BSTR(&varresult)));
985 VariantClear(&varresult);
987 /* call get_Name (direct) */
989 hr = IWidget_get_Name(pWidget, &bstr);
990 ok_ole_success(hr, IWidget_get_Name);
991 ok(!lstrcmpW(bstr, szCat), "IWidget_get_Name should have returned string \"Cat\" instead of %s\n", wine_dbgstr_w(bstr));
994 /* call DoSomething */
995 VariantInit(&vararg[0]);
996 VariantInit(&vararg[1]);
997 V_VT(&vararg[1]) = VT_R8;
998 V_R8(&vararg[1]) = 3.141;
999 dispparams.cNamedArgs = 0;
1000 dispparams.cArgs = 2;
1001 dispparams.rgdispidNamedArgs = NULL;
1002 dispparams.rgvarg = vararg;
1003 VariantInit(&varresult);
1004 hr = IDispatch_Invoke(pDispatch, DISPID_TM_DOSOMETHING, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
1005 ok_ole_success(hr, IDispatch_Invoke);
1006 ok(V_VT(&varresult) == VT_EMPTY, "varresult should be VT_EMPTY\n");
1007 VariantClear(&varresult);
1009 /* call get_State */
1010 dispparams.cNamedArgs = 0;
1011 dispparams.cArgs = 0;
1012 dispparams.rgdispidNamedArgs = NULL;
1013 dispparams.rgvarg = NULL;
1014 hr = IDispatch_Invoke(pDispatch, DISPID_TM_STATE, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
1015 ok_ole_success(hr, IDispatch_Invoke);
1016 ok((V_VT(&varresult) == VT_I4) && (V_I4(&varresult) == STATE_WIDGETIFIED), "Return val mismatch\n");
1018 /* call get_State (direct) */
1019 hr = IWidget_get_State(pWidget, &the_state);
1020 ok_ole_success(hr, IWidget_get_state);
1021 ok(the_state == STATE_WIDGETIFIED, "should have returned WIDGET_WIDGETIFIED instead of %d\n", the_state);
1023 /* call put_State */
1024 the_state = STATE_WIDGETIFIED;
1025 VariantInit(&vararg[0]);
1026 V_VT(&vararg[0]) = VT_BYREF|VT_I4;
1027 V_I4REF(&vararg[0]) = (int *)&the_state;
1028 dispparams.cNamedArgs = 1;
1029 dispparams.cArgs = 1;
1030 dispparams.rgdispidNamedArgs = &dispidNamed;
1031 dispparams.rgvarg = vararg;
1032 hr = IDispatch_Invoke(pDispatch, DISPID_TM_STATE, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYPUT, &dispparams, &varresult, &excepinfo, NULL);
1033 ok_ole_success(hr, IDispatch_Invoke);
1036 bstr = SysAllocString(szTestTest);
1037 VariantInit(&vararg[0]);
1038 V_VT(&vararg[0]) = VT_BYREF|VT_BSTR;
1039 V_BSTRREF(&vararg[0]) = &bstr;
1040 dispparams.cNamedArgs = 0;
1041 dispparams.cArgs = 1;
1042 dispparams.rgdispidNamedArgs = NULL;
1043 dispparams.rgvarg = vararg;
1044 VariantInit(&varresult);
1045 hr = IDispatch_Invoke(pDispatch, DISPID_TM_MAP, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
1046 ok_ole_success(hr, IDispatch_Invoke);
1047 ok(V_VT(&varresult) == VT_BSTR, "Return value should be of type BSTR instead of %d\n", V_VT(&varresult));
1048 ok(!lstrcmpW(V_BSTR(&varresult), szTestTest), "Return value should have been \"TestTest\" instead of %s\n", wine_dbgstr_w(V_BSTR(&varresult)));
1049 VariantClear(&varresult);
1051 /* call SetOleColor with large negative VT_I4 param */
1052 VariantInit(&vararg[0]);
1053 V_VT(&vararg[0]) = VT_I4;
1054 V_I4(&vararg[0]) = 0x80000005;
1055 dispparams.cNamedArgs = 0;
1056 dispparams.cArgs = 1;
1057 dispparams.rgdispidNamedArgs = NULL;
1058 dispparams.rgvarg = vararg;
1059 hr = IDispatch_Invoke(pDispatch, DISPID_TM_SETOLECOLOR, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, NULL, &excepinfo, NULL);
1060 ok_ole_success(hr, IDispatch_Invoke);
1062 /* call GetOleColor */
1063 dispparams.cNamedArgs = 0;
1064 dispparams.cArgs = 0;
1065 dispparams.rgdispidNamedArgs = NULL;
1066 dispparams.rgvarg = NULL;
1067 VariantInit(&varresult);
1068 hr = IDispatch_Invoke(pDispatch, DISPID_TM_GETOLECOLOR, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
1069 ok_ole_success(hr, IDispatch_Invoke);
1070 VariantClear(&varresult);
1073 dispparams.cNamedArgs = 0;
1074 dispparams.cArgs = 0;
1075 dispparams.rgdispidNamedArgs = NULL;
1076 dispparams.rgvarg = NULL;
1077 VariantInit(&varresult);
1078 hr = IDispatch_Invoke(pDispatch, DISPID_TM_CLONE, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
1079 ok_ole_success(hr, IDispatch_Invoke);
1080 ok(V_VT(&varresult) == VT_DISPATCH, "vt %x\n", V_VT(&varresult));
1081 VariantClear(&varresult);
1083 /* call CloneInterface */
1084 dispparams.cNamedArgs = 0;
1085 dispparams.cArgs = 0;
1086 dispparams.rgdispidNamedArgs = NULL;
1087 dispparams.rgvarg = NULL;
1088 VariantInit(&varresult);
1089 hr = IDispatch_Invoke(pDispatch, DISPID_TM_CLONEINTERFACE, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
1090 ok_ole_success(hr, IDispatch_Invoke);
1091 ok(V_VT(&varresult) == VT_DISPATCH, "vt %x\n", V_VT(&varresult));
1092 VariantClear(&varresult);
1094 /* call CloneDispatch with automatic value getting */
1095 V_VT(&vararg[0]) = VT_I2;
1096 V_I2(&vararg[0]) = 1;
1097 dispparams.cNamedArgs = 0;
1098 dispparams.rgdispidNamedArgs = NULL;
1099 dispparams.cArgs = 1;
1100 dispparams.rgvarg = vararg;
1101 VariantInit(&varresult);
1102 hr = IDispatch_Invoke(pDispatch, DISPID_TM_CLONEDISPATCH, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
1103 ok_ole_success(hr, IDispatch_Invoke);
1105 ok(excepinfo.wCode == 0x0 && excepinfo.scode == S_OK,
1106 "EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
1107 excepinfo.wCode, excepinfo.scode);
1109 ok(V_VT(&varresult) == VT_I2, "V_VT(&varresult) was %d instead of VT_I2\n", V_VT(&varresult));
1110 ok(V_I2(&varresult) == 1234, "V_I2(&varresult) was %d instead of 1234\n", V_I2(&varresult));
1111 VariantClear(&varresult);
1113 /* call CloneCoclass */
1114 dispparams.cNamedArgs = 0;
1115 dispparams.cArgs = 0;
1116 dispparams.rgdispidNamedArgs = NULL;
1117 dispparams.rgvarg = NULL;
1118 VariantInit(&varresult);
1119 hr = IDispatch_Invoke(pDispatch, DISPID_TM_CLONECOCLASS, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
1120 ok_ole_success(hr, IDispatch_Invoke);
1122 ok(excepinfo.wCode == 0x0 && excepinfo.scode == S_OK,
1123 "EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
1124 excepinfo.wCode, excepinfo.scode);
1126 ok(V_VT(&varresult) == VT_DISPATCH, "V_VT(&varresult) was %d instead of VT_DISPATCH\n", V_VT(&varresult));
1127 ok(!V_DISPATCH(&varresult), "V_DISPATCH(&varresult) should be NULL instead of %p\n", V_DISPATCH(&varresult));
1128 VariantClear(&varresult);
1130 /* call Value with a VT_VARIANT|VT_BYREF type */
1131 V_VT(&vararg[0]) = VT_VARIANT|VT_BYREF;
1132 V_VARIANTREF(&vararg[0]) = &vararg[1];
1133 V_VT(&vararg[1]) = VT_I2;
1134 V_I2(&vararg[1]) = 1;
1135 dispparams.cNamedArgs = 0;
1136 dispparams.rgdispidNamedArgs = NULL;
1137 dispparams.cArgs = 1;
1138 dispparams.rgvarg = vararg;
1139 VariantInit(&varresult);
1140 hr = IDispatch_Invoke(pDispatch, DISPID_VALUE, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
1141 ok_ole_success(hr, IDispatch_Invoke);
1143 ok(excepinfo.wCode == 0x0 && excepinfo.scode == S_OK,
1144 "EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
1145 excepinfo.wCode, excepinfo.scode);
1147 ok(V_VT(&varresult) == VT_I2, "V_VT(&varresult) was %d instead of VT_I2\n", V_VT(&varresult));
1148 ok(V_I2(&varresult) == 1234, "V_I2(&varresult) was %d instead of 1234\n", V_I2(&varresult));
1149 VariantClear(&varresult);
1151 /* call Variant - exercises variant copying in ITypeInfo::Invoke and
1152 * handling of void return types */
1153 /* use a big type to ensure that the variant was properly copied into the
1154 * destination function's args */
1155 V_VT(&vararg[0]) = VT_CY;
1156 S(V_CY(&vararg[0])).Hi = 0xdababe;
1157 S(V_CY(&vararg[0])).Lo = 0xdeadbeef;
1158 dispparams.cNamedArgs = 0;
1159 dispparams.cArgs = 1;
1160 dispparams.rgdispidNamedArgs = NULL;
1161 dispparams.rgvarg = vararg;
1162 VariantInit(&varresult);
1163 hr = IDispatch_Invoke(pDispatch, DISPID_TM_VARIANT, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
1164 ok_ole_success(hr, IDispatch_Invoke);
1165 VariantClear(&varresult);
1168 VariantInit(&vararg[3]);
1169 V_VT(&vararg[3]) = VT_I4;
1170 V_I4(&vararg[3]) = 3;
1171 VariantInit(&vararg[2]);
1172 V_VT(&vararg[2]) = VT_I4;
1173 V_I4(&vararg[2]) = 0;
1174 VariantInit(&vararg[1]);
1175 V_VT(&vararg[1]) = VT_I4;
1176 V_I4(&vararg[1]) = 1;
1177 VariantInit(&vararg[0]);
1178 V_VT(&vararg[0]) = VT_I4;
1179 V_I4(&vararg[0]) = 2;
1180 dispparams.cNamedArgs = 0;
1181 dispparams.cArgs = 4;
1182 dispparams.rgdispidNamedArgs = NULL;
1183 dispparams.rgvarg = vararg;
1184 hr = IDispatch_Invoke(pDispatch, DISPID_TM_VARARG, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
1185 ok_ole_success(hr, ITypeInfo_Invoke);
1187 /* call VarArg, even one (non-optional, non-safearray) named argument is not allowed */
1189 dispparams.cNamedArgs = 1;
1190 dispparams.rgdispidNamedArgs = &dispidNamed;
1191 hr = IDispatch_Invoke(pDispatch, DISPID_TM_VARARG, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
1192 ok(hr == DISP_E_NONAMEDARGS, "IDispatch_Invoke should have returned DISP_E_NONAMEDARGS instead of 0x%08x\n", hr);
1193 dispidNamed = DISPID_PROPERTYPUT;
1196 dispparams.cNamedArgs = 0;
1197 dispparams.cArgs = 0;
1198 dispparams.rgdispidNamedArgs = NULL;
1199 dispparams.rgvarg = NULL;
1200 VariantInit(&varresult);
1201 hr = IDispatch_Invoke(pDispatch, DISPID_TM_ERROR, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, NULL, &excepinfo, NULL);
1202 ok(hr == DISP_E_EXCEPTION, "IDispatch_Invoke should have returned DISP_E_EXCEPTION instead of 0x%08x\n", hr);
1203 ok(excepinfo.wCode == 0x0 && excepinfo.scode == E_NOTIMPL,
1204 "EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
1205 excepinfo.wCode, excepinfo.scode);
1206 VariantClear(&varresult);
1209 pTypeInfo = NonOleAutomation_GetTypeInfo();
1210 dispparams.cNamedArgs = 0;
1211 dispparams.cArgs = 0;
1212 dispparams.rgdispidNamedArgs = NULL;
1213 dispparams.rgvarg = NULL;
1214 VariantInit(&varresult);
1215 hr = ITypeInfo_Invoke(pTypeInfo, &NonOleAutomation, DISPID_NOA_BSTRRET, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
1216 ok_ole_success(hr, ITypeInfo_Invoke);
1217 ok(V_VT(&varresult) == VT_BSTR, "V_VT(&varresult) should be VT_BSTR instead of %d\n", V_VT(&varresult));
1218 ok(V_BSTR(&varresult) != NULL, "V_BSTR(&varresult) should not be NULL\n");
1220 VariantClear(&varresult);
1221 ITypeInfo_Release(pTypeInfo);
1223 /* tests call put_Name without named arg */
1224 VariantInit(&vararg[0]);
1225 dispparams.cNamedArgs = 0;
1226 dispparams.rgdispidNamedArgs = NULL;
1227 dispparams.cArgs = 1;
1228 dispparams.rgvarg = vararg;
1229 VariantInit(&varresult);
1230 hr = IDispatch_Invoke(pDispatch, DISPID_TM_NAME, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYPUT, &dispparams, &varresult, &excepinfo, NULL);
1231 ok(hr == DISP_E_PARAMNOTFOUND, "IDispatch_Invoke should have returned DISP_E_PARAMNOTFOUND instead of 0x%08x\n", hr);
1232 VariantClear(&varresult);
1234 /* tests param type that cannot be coerced */
1235 VariantInit(&vararg[0]);
1236 V_VT(&vararg[0]) = VT_UNKNOWN;
1237 V_UNKNOWN(&vararg[0]) = NULL;
1238 dispparams.cNamedArgs = 1;
1239 dispparams.rgdispidNamedArgs = &dispidNamed;
1240 dispparams.cArgs = 1;
1241 dispparams.rgvarg = vararg;
1242 VariantInit(&varresult);
1243 #if 0 /* NULL unknown not currently marshaled correctly */
1244 hr = IDispatch_Invoke(pDispatch, DISPID_TM_NAME, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYPUT, &dispparams, &varresult, &excepinfo, NULL);
1245 ok(hr == DISP_E_TYPEMISMATCH, "IDispatch_Invoke should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hr);
1247 VariantClear(&varresult);
1249 /* tests bad param type */
1250 VariantInit(&vararg[0]);
1251 V_VT(&vararg[0]) = VT_CLSID;
1252 V_BYREF(&vararg[0]) = NULL;
1253 dispparams.cNamedArgs = 1;
1254 dispparams.rgdispidNamedArgs = &dispidNamed;
1255 dispparams.cArgs = 1;
1256 dispparams.rgvarg = vararg;
1257 VariantInit(&varresult);
1258 hr = IDispatch_Invoke(pDispatch, DISPID_TM_NAME, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYPUT, &dispparams, &varresult, &excepinfo, NULL);
1259 ok(hr == DISP_E_BADVARTYPE, "IDispatch_Invoke should have returned DISP_E_BADVARTYPE instead of 0x%08x\n", hr);
1260 VariantClear(&varresult);
1262 /* tests too small param count */
1263 dispparams.cNamedArgs = 0;
1264 dispparams.rgdispidNamedArgs = NULL;
1265 dispparams.cArgs = 0;
1266 dispparams.rgvarg = NULL;
1267 VariantInit(&varresult);
1268 hr = IDispatch_Invoke(pDispatch, DISPID_TM_DOSOMETHING, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
1269 ok(hr == DISP_E_BADPARAMCOUNT, "IDispatch_Invoke should have returned DISP_E_BADPARAMCOUNT instead of 0x%08x\n", hr);
1270 VariantClear(&varresult);
1272 /* tests propget function with large param count */
1273 VariantInit(&vararg[0]);
1274 V_VT(&vararg[0]) = VT_BSTR;
1275 V_BSTR(&vararg[0]) = NULL;
1276 V_VT(&vararg[1]) = VT_I4;
1277 V_I4(&vararg[1]) = 1;
1278 dispparams.cNamedArgs = 0;
1279 dispparams.cArgs = 2;
1280 dispparams.rgdispidNamedArgs = NULL;
1281 dispparams.rgvarg = vararg;
1282 hr = IDispatch_Invoke(pDispatch, DISPID_TM_STATE, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
1283 ok(hr == DISP_E_NOTACOLLECTION, "IDispatch_Invoke should have returned DISP_E_NOTACOLLECTION instead of 0x%08x\n", hr);
1285 IDispatch_Release(pDispatch);
1286 IWidget_Release(pWidget);
1288 trace("calling end_host_object\n");
1289 end_host_object(tid, thread);
1292 static void test_DispCallFunc(void)
1294 static const WCHAR szEmpty[] = { 0 };
1295 VARTYPE rgvt[] = { VT_R8, VT_BSTR, VT_BSTR, VT_VARIANT|VT_BYREF };
1296 VARIANTARG vararg[4];
1298 VARIANTARG *rgpvarg[4] = { &vararg[0], &vararg[1], &vararg[2], &vararg[3] };
1299 VARIANTARG varresult;
1301 IWidget *pWidget = Widget_Create();
1302 V_VT(&vararg[0]) = VT_R8;
1303 V_R8(&vararg[0]) = 3.141;
1304 V_VT(&vararg[1]) = VT_BSTR;
1305 V_BSTR(&vararg[1]) = SysAllocString(szEmpty);
1306 V_VT(&vararg[2]) = VT_BSTR;
1307 V_BSTR(&vararg[2]) = SysAllocString(szEmpty);
1308 V_VT(&vararg[3]) = VT_VARIANT|VT_BYREF;
1309 V_VARIANTREF(&vararg[3]) = &varref;
1310 V_VT(&varref) = VT_ERROR;
1311 V_ERROR(&varref) = DISP_E_PARAMNOTFOUND;
1312 VariantInit(&varresult);
1313 hr = DispCallFunc(pWidget, 36, CC_STDCALL, VT_UI4, 4, rgvt, rgpvarg, &varresult);
1314 ok_ole_success(hr, DispCallFunc);
1315 VariantClear(&varresult);
1316 VariantClear(&vararg[1]);
1317 VariantClear(&vararg[2]);
1318 IWidget_Release(pWidget);
1321 static void test_StaticWidget(void)
1323 ITypeInfo *type_info;
1324 DISPPARAMS dispparams;
1325 VARIANTARG vararg[4];
1326 EXCEPINFO excepinfo;
1330 type_info = get_type_info(&IID_IStaticWidget);
1333 dispparams.cNamedArgs = 0;
1334 dispparams.cArgs = 1;
1335 dispparams.rgdispidNamedArgs = NULL;
1336 dispparams.rgvarg = vararg;
1337 V_VT(vararg) = VT_DISPATCH;
1338 V_DISPATCH(vararg) = (IDispatch*)&TestDualDisp;
1339 VariantInit(&varresult);
1340 hr = ITypeInfo_Invoke(type_info, &StaticWidget, DISPID_TM_TESTDUAL, DISPATCH_METHOD,
1341 &dispparams, &varresult, &excepinfo, NULL);
1342 ok_ole_success(hr, IDispatch_Invoke);
1343 ok(V_VT(&varresult) == VT_EMPTY, "vt %x\n", V_VT(&varresult));
1344 VariantClear(&varresult);
1346 ITypeInfo_Release(type_info);
1349 START_TEST(tmarshal)
1353 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
1355 hr = register_current_module_typelib();
1356 ok_ole_success(hr, register_current_module_typelib);
1358 test_typelibmarshal();
1359 test_DispCallFunc();
1360 test_StaticWidget();
1362 hr = UnRegisterTypeLib(&LIBID_TestTypelib, 1, 0, LOCALE_NEUTRAL, 1);
1363 ok_ole_success(hr, UnRegisterTypeLib);