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];
704 CHAR pathA[MAX_PATH];
708 GetModuleFileNameA(NULL, pathA, MAX_PATH);
709 MultiByteToWideChar(CP_ACP, 0, pathA, -1, path, MAX_PATH);
711 hr = LoadTypeLib(path, &typelib);
714 hr = RegisterTypeLib(typelib, path, NULL);
715 ITypeLib_Release(typelib);
720 static ITypeInfo *get_type_info(REFIID riid)
722 ITypeInfo *pTypeInfo;
726 hr = LoadRegTypeLib(&LIBID_TestTypelib, 1, 0, LOCALE_NEUTRAL, &pTypeLib);
727 ok_ole_success(hr, LoadRegTypeLib);
731 hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, riid, &pTypeInfo);
732 ITypeLib_Release(pTypeLib);
733 ok_ole_success(hr, ITypeLib_GetTypeInfoOfGuid);
740 static IWidget *Widget_Create(void)
743 ITypeInfo *pTypeInfo;
746 pTypeInfo = get_type_info(&IID_IWidget);
750 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
751 This->lpVtbl = &Widget_VTable;
753 This->pDispatchUnknown = NULL;
755 hr = CreateStdDispatch((IUnknown *)&This->lpVtbl, This, pTypeInfo, &This->pDispatchUnknown);
756 ok_ole_success(hr, CreateStdDispatch);
757 ITypeInfo_Release(pTypeInfo);
760 return (IWidget *)&This->lpVtbl;
763 HeapFree(GetProcessHeap(), 0, This);
768 HRESULT WINAPI KindaEnum_QueryInterface(
769 IKindaEnumWidget *iface,
770 /* [in] */ REFIID riid,
771 /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject)
773 if (IsEqualIID(riid, &IID_IKindaEnumWidget) || IsEqualIID(riid, &IID_IUnknown))
775 IKindaEnumWidget_AddRef(iface);
782 return E_NOINTERFACE;
786 ULONG WINAPI KindaEnum_AddRef(
787 IKindaEnumWidget *iface)
789 KindaEnum *This = (KindaEnum *)iface;
791 return InterlockedIncrement(&This->refs);
794 ULONG WINAPI KindaEnum_Release(
795 IKindaEnumWidget *iface)
797 KindaEnum *This = (KindaEnum *)iface;
798 ULONG refs = InterlockedDecrement(&This->refs);
801 memset(This, 0xcc, sizeof(*This));
802 HeapFree(GetProcessHeap(), 0, This);
803 trace("KindaEnumWidget destroyed!\n");
809 HRESULT WINAPI KindaEnum_Next(
810 IKindaEnumWidget *iface,
811 /* [out] */ IWidget __RPC_FAR *__RPC_FAR *widget)
813 *widget = Widget_Create();
817 return E_OUTOFMEMORY;
820 HRESULT WINAPI KindaEnum_Count(
821 IKindaEnumWidget *iface,
822 /* [out] */ unsigned long __RPC_FAR *count)
827 HRESULT WINAPI KindaEnum_Reset(
828 IKindaEnumWidget *iface)
833 HRESULT WINAPI KindaEnum_Clone(
834 IKindaEnumWidget *iface,
835 /* [out] */ IKindaEnumWidget __RPC_FAR *__RPC_FAR *ppenum)
840 static const IKindaEnumWidgetVtbl KindaEnumWidget_VTable =
842 KindaEnum_QueryInterface,
851 static IKindaEnumWidget *KindaEnumWidget_Create(void)
855 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
856 if (!This) return NULL;
857 This->lpVtbl = &KindaEnumWidget_VTable;
859 return (IKindaEnumWidget *)This;
862 static HRESULT WINAPI NonOleAutomation_QueryInterface(INonOleAutomation *iface, REFIID riid, void **ppv)
864 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_INonOleAutomation))
866 *(INonOleAutomation **)ppv = iface;
870 return E_NOINTERFACE;
873 static ULONG WINAPI NonOleAutomation_AddRef(INonOleAutomation *iface)
878 static ULONG WINAPI NonOleAutomation_Release(INonOleAutomation *iface)
883 static BSTR WINAPI NonOleAutomation_BstrRet(INonOleAutomation *iface)
885 static const WCHAR wszTestString[] = {'T','h','i','s',' ','i','s',' ','a',' ','t','e','s','t',' ','s','t','r','i','n','g',0};
886 return SysAllocString(wszTestString);
889 static INonOleAutomationVtbl NonOleAutomation_VTable =
891 NonOleAutomation_QueryInterface,
892 NonOleAutomation_AddRef,
893 NonOleAutomation_Release,
894 NonOleAutomation_BstrRet,
897 static INonOleAutomation NonOleAutomation = { &NonOleAutomation_VTable };
899 static ITypeInfo *NonOleAutomation_GetTypeInfo(void)
902 HRESULT hr = LoadRegTypeLib(&LIBID_TestTypelib, 1, 0, LOCALE_NEUTRAL, &pTypeLib);
903 ok_ole_success(hr, LoadRegTypeLib);
906 ITypeInfo *pTypeInfo;
907 hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, &IID_INonOleAutomation, &pTypeInfo);
908 ok_ole_success(hr, ITypeLib_GetTypeInfoOfGuid);
914 static void test_typelibmarshal(void)
916 static const WCHAR szCat[] = { 'C','a','t',0 };
917 static const WCHAR szTestTest[] = { 'T','e','s','t','T','e','s','t',0 };
918 static WCHAR szSuperman[] = { 'S','u','p','e','r','m','a','n',0 };
920 IKindaEnumWidget *pKEW = KindaEnumWidget_Create();
923 IDispatch *pDispatch;
924 static const LARGE_INTEGER ullZero;
927 DISPID dispidNamed = DISPID_PROPERTYPUT;
928 DISPPARAMS dispparams;
929 VARIANTARG vararg[4];
934 ITypeInfo *pTypeInfo;
936 ok(pKEW != NULL, "Widget creation failed\n");
938 hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
939 ok_ole_success(hr, CreateStreamOnHGlobal);
940 tid = start_host_object(pStream, &IID_IKindaEnumWidget, (IUnknown *)pKEW, MSHLFLAGS_NORMAL, &thread);
941 IKindaEnumWidget_Release(pKEW);
943 IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
944 hr = CoUnmarshalInterface(pStream, &IID_IKindaEnumWidget, (void **)&pKEW);
945 ok_ole_success(hr, CoUnmarshalInterface);
946 IStream_Release(pStream);
948 hr = IKindaEnumWidget_Next(pKEW, &pWidget);
949 ok_ole_success(hr, IKindaEnumWidget_Next);
951 IKindaEnumWidget_Release(pKEW);
953 hr = IWidget_QueryInterface(pWidget, &IID_IDispatch, (void **)&pDispatch);
956 VariantInit(&vararg[0]);
957 dispparams.cNamedArgs = 1;
958 dispparams.rgdispidNamedArgs = &dispidNamed;
959 dispparams.cArgs = 1;
960 dispparams.rgvarg = vararg;
961 VariantInit(&varresult);
962 hr = IDispatch_Invoke(pDispatch, DISPID_TM_NAME, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYPUT, &dispparams, &varresult, &excepinfo, NULL);
963 ok_ole_success(hr, IDispatch_Invoke);
964 ok(excepinfo.wCode == 0x0 && excepinfo.scode == S_OK,
965 "EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
966 excepinfo.wCode, excepinfo.scode);
967 VariantClear(&varresult);
969 /* call put_Name (direct) */
970 bstr = SysAllocString(szSuperman);
971 hr = IWidget_put_Name(pWidget, bstr);
972 ok_ole_success(hr, IWidget_put_Name);
976 dispparams.cNamedArgs = 0;
977 dispparams.rgdispidNamedArgs = NULL;
978 dispparams.cArgs = 0;
979 dispparams.rgvarg = NULL;
980 VariantInit(&varresult);
981 hr = IDispatch_Invoke(pDispatch, DISPID_TM_NAME, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
982 ok_ole_success(hr, IDispatch_Invoke);
983 ok(excepinfo.wCode == 0x0 && excepinfo.scode == S_OK,
984 "EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
985 excepinfo.wCode, excepinfo.scode);
986 trace("Name = %s\n", wine_dbgstr_w(V_BSTR(&varresult)));
987 VariantClear(&varresult);
989 /* call get_Name (direct) */
991 hr = IWidget_get_Name(pWidget, &bstr);
992 ok_ole_success(hr, IWidget_get_Name);
993 ok(!lstrcmpW(bstr, szCat), "IWidget_get_Name should have returned string \"Cat\" instead of %s\n", wine_dbgstr_w(bstr));
996 /* call DoSomething */
997 VariantInit(&vararg[0]);
998 VariantInit(&vararg[1]);
999 V_VT(&vararg[1]) = VT_R8;
1000 V_R8(&vararg[1]) = 3.141;
1001 dispparams.cNamedArgs = 0;
1002 dispparams.cArgs = 2;
1003 dispparams.rgdispidNamedArgs = NULL;
1004 dispparams.rgvarg = vararg;
1005 VariantInit(&varresult);
1006 hr = IDispatch_Invoke(pDispatch, DISPID_TM_DOSOMETHING, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
1007 ok_ole_success(hr, IDispatch_Invoke);
1008 ok(V_VT(&varresult) == VT_EMPTY, "varresult should be VT_EMPTY\n");
1009 VariantClear(&varresult);
1011 /* call get_State */
1012 dispparams.cNamedArgs = 0;
1013 dispparams.cArgs = 0;
1014 dispparams.rgdispidNamedArgs = NULL;
1015 dispparams.rgvarg = NULL;
1016 hr = IDispatch_Invoke(pDispatch, DISPID_TM_STATE, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
1017 ok_ole_success(hr, IDispatch_Invoke);
1018 ok((V_VT(&varresult) == VT_I4) && (V_I4(&varresult) == STATE_WIDGETIFIED), "Return val mismatch\n");
1020 /* call get_State (direct) */
1021 hr = IWidget_get_State(pWidget, &the_state);
1022 ok_ole_success(hr, IWidget_get_state);
1023 ok(the_state == STATE_WIDGETIFIED, "should have returned WIDGET_WIDGETIFIED instead of %d\n", the_state);
1025 /* call put_State */
1026 the_state = STATE_WIDGETIFIED;
1027 VariantInit(&vararg[0]);
1028 V_VT(&vararg[0]) = VT_BYREF|VT_I4;
1029 V_I4REF(&vararg[0]) = (int *)&the_state;
1030 dispparams.cNamedArgs = 1;
1031 dispparams.cArgs = 1;
1032 dispparams.rgdispidNamedArgs = &dispidNamed;
1033 dispparams.rgvarg = vararg;
1034 hr = IDispatch_Invoke(pDispatch, DISPID_TM_STATE, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYPUT, &dispparams, &varresult, &excepinfo, NULL);
1035 ok_ole_success(hr, IDispatch_Invoke);
1038 bstr = SysAllocString(szTestTest);
1039 VariantInit(&vararg[0]);
1040 V_VT(&vararg[0]) = VT_BYREF|VT_BSTR;
1041 V_BSTRREF(&vararg[0]) = &bstr;
1042 dispparams.cNamedArgs = 0;
1043 dispparams.cArgs = 1;
1044 dispparams.rgdispidNamedArgs = NULL;
1045 dispparams.rgvarg = vararg;
1046 VariantInit(&varresult);
1047 hr = IDispatch_Invoke(pDispatch, DISPID_TM_MAP, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
1048 ok_ole_success(hr, IDispatch_Invoke);
1049 ok(V_VT(&varresult) == VT_BSTR, "Return value should be of type BSTR instead of %d\n", V_VT(&varresult));
1050 ok(!lstrcmpW(V_BSTR(&varresult), szTestTest), "Return value should have been \"TestTest\" instead of %s\n", wine_dbgstr_w(V_BSTR(&varresult)));
1051 VariantClear(&varresult);
1053 /* call SetOleColor with large negative VT_I4 param */
1054 VariantInit(&vararg[0]);
1055 V_VT(&vararg[0]) = VT_I4;
1056 V_I4(&vararg[0]) = 0x80000005;
1057 dispparams.cNamedArgs = 0;
1058 dispparams.cArgs = 1;
1059 dispparams.rgdispidNamedArgs = NULL;
1060 dispparams.rgvarg = vararg;
1061 hr = IDispatch_Invoke(pDispatch, DISPID_TM_SETOLECOLOR, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, NULL, &excepinfo, NULL);
1062 ok_ole_success(hr, IDispatch_Invoke);
1064 /* call GetOleColor */
1065 dispparams.cNamedArgs = 0;
1066 dispparams.cArgs = 0;
1067 dispparams.rgdispidNamedArgs = NULL;
1068 dispparams.rgvarg = NULL;
1069 VariantInit(&varresult);
1070 hr = IDispatch_Invoke(pDispatch, DISPID_TM_GETOLECOLOR, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
1071 ok_ole_success(hr, IDispatch_Invoke);
1072 VariantClear(&varresult);
1075 dispparams.cNamedArgs = 0;
1076 dispparams.cArgs = 0;
1077 dispparams.rgdispidNamedArgs = NULL;
1078 dispparams.rgvarg = NULL;
1079 VariantInit(&varresult);
1080 hr = IDispatch_Invoke(pDispatch, DISPID_TM_CLONE, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
1081 ok_ole_success(hr, IDispatch_Invoke);
1082 ok(V_VT(&varresult) == VT_DISPATCH, "vt %x\n", V_VT(&varresult));
1083 VariantClear(&varresult);
1085 /* call CloneInterface */
1086 dispparams.cNamedArgs = 0;
1087 dispparams.cArgs = 0;
1088 dispparams.rgdispidNamedArgs = NULL;
1089 dispparams.rgvarg = NULL;
1090 VariantInit(&varresult);
1091 hr = IDispatch_Invoke(pDispatch, DISPID_TM_CLONEINTERFACE, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
1092 ok_ole_success(hr, IDispatch_Invoke);
1093 ok(V_VT(&varresult) == VT_DISPATCH, "vt %x\n", V_VT(&varresult));
1094 VariantClear(&varresult);
1096 /* call CloneDispatch with automatic value getting */
1097 V_VT(&vararg[0]) = VT_I2;
1098 V_I2(&vararg[0]) = 1;
1099 dispparams.cNamedArgs = 0;
1100 dispparams.rgdispidNamedArgs = NULL;
1101 dispparams.cArgs = 1;
1102 dispparams.rgvarg = vararg;
1103 VariantInit(&varresult);
1104 hr = IDispatch_Invoke(pDispatch, DISPID_TM_CLONEDISPATCH, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
1105 ok_ole_success(hr, IDispatch_Invoke);
1107 ok(excepinfo.wCode == 0x0 && excepinfo.scode == S_OK,
1108 "EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
1109 excepinfo.wCode, excepinfo.scode);
1111 ok(V_VT(&varresult) == VT_I2, "V_VT(&varresult) was %d instead of VT_I2\n", V_VT(&varresult));
1112 ok(V_I2(&varresult) == 1234, "V_I2(&varresult) was %d instead of 1234\n", V_I2(&varresult));
1113 VariantClear(&varresult);
1115 /* call CloneCoclass */
1116 dispparams.cNamedArgs = 0;
1117 dispparams.cArgs = 0;
1118 dispparams.rgdispidNamedArgs = NULL;
1119 dispparams.rgvarg = NULL;
1120 VariantInit(&varresult);
1121 hr = IDispatch_Invoke(pDispatch, DISPID_TM_CLONECOCLASS, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
1122 ok_ole_success(hr, IDispatch_Invoke);
1124 ok(excepinfo.wCode == 0x0 && excepinfo.scode == S_OK,
1125 "EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
1126 excepinfo.wCode, excepinfo.scode);
1128 ok(V_VT(&varresult) == VT_DISPATCH, "V_VT(&varresult) was %d instead of VT_DISPATCH\n", V_VT(&varresult));
1129 ok(!V_DISPATCH(&varresult), "V_DISPATCH(&varresult) should be NULL instead of %p\n", V_DISPATCH(&varresult));
1130 VariantClear(&varresult);
1132 /* call Value with a VT_VARIANT|VT_BYREF type */
1133 V_VT(&vararg[0]) = VT_VARIANT|VT_BYREF;
1134 V_VARIANTREF(&vararg[0]) = &vararg[1];
1135 V_VT(&vararg[1]) = VT_I2;
1136 V_I2(&vararg[1]) = 1;
1137 dispparams.cNamedArgs = 0;
1138 dispparams.rgdispidNamedArgs = NULL;
1139 dispparams.cArgs = 1;
1140 dispparams.rgvarg = vararg;
1141 VariantInit(&varresult);
1142 hr = IDispatch_Invoke(pDispatch, DISPID_VALUE, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
1143 ok_ole_success(hr, IDispatch_Invoke);
1145 ok(excepinfo.wCode == 0x0 && excepinfo.scode == S_OK,
1146 "EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
1147 excepinfo.wCode, excepinfo.scode);
1149 ok(V_VT(&varresult) == VT_I2, "V_VT(&varresult) was %d instead of VT_I2\n", V_VT(&varresult));
1150 ok(V_I2(&varresult) == 1234, "V_I2(&varresult) was %d instead of 1234\n", V_I2(&varresult));
1151 VariantClear(&varresult);
1153 /* call Variant - exercises variant copying in ITypeInfo::Invoke and
1154 * handling of void return types */
1155 /* use a big type to ensure that the variant was properly copied into the
1156 * destination function's args */
1157 V_VT(&vararg[0]) = VT_CY;
1158 S(V_CY(&vararg[0])).Hi = 0xdababe;
1159 S(V_CY(&vararg[0])).Lo = 0xdeadbeef;
1160 dispparams.cNamedArgs = 0;
1161 dispparams.cArgs = 1;
1162 dispparams.rgdispidNamedArgs = NULL;
1163 dispparams.rgvarg = vararg;
1164 VariantInit(&varresult);
1165 hr = IDispatch_Invoke(pDispatch, DISPID_TM_VARIANT, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
1166 ok_ole_success(hr, IDispatch_Invoke);
1167 VariantClear(&varresult);
1170 VariantInit(&vararg[3]);
1171 V_VT(&vararg[3]) = VT_I4;
1172 V_I4(&vararg[3]) = 3;
1173 VariantInit(&vararg[2]);
1174 V_VT(&vararg[2]) = VT_I4;
1175 V_I4(&vararg[2]) = 0;
1176 VariantInit(&vararg[1]);
1177 V_VT(&vararg[1]) = VT_I4;
1178 V_I4(&vararg[1]) = 1;
1179 VariantInit(&vararg[0]);
1180 V_VT(&vararg[0]) = VT_I4;
1181 V_I4(&vararg[0]) = 2;
1182 dispparams.cNamedArgs = 0;
1183 dispparams.cArgs = 4;
1184 dispparams.rgdispidNamedArgs = NULL;
1185 dispparams.rgvarg = vararg;
1186 hr = IDispatch_Invoke(pDispatch, DISPID_TM_VARARG, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
1187 ok_ole_success(hr, ITypeInfo_Invoke);
1189 /* call VarArg, even one (non-optional, non-safearray) named argument is not allowed */
1191 dispparams.cNamedArgs = 1;
1192 dispparams.rgdispidNamedArgs = &dispidNamed;
1193 hr = IDispatch_Invoke(pDispatch, DISPID_TM_VARARG, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
1194 ok(hr == DISP_E_NONAMEDARGS, "IDispatch_Invoke should have returned DISP_E_NONAMEDARGS instead of 0x%08x\n", hr);
1195 dispidNamed = DISPID_PROPERTYPUT;
1198 dispparams.cNamedArgs = 0;
1199 dispparams.cArgs = 0;
1200 dispparams.rgdispidNamedArgs = NULL;
1201 dispparams.rgvarg = NULL;
1202 VariantInit(&varresult);
1203 hr = IDispatch_Invoke(pDispatch, DISPID_TM_ERROR, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, NULL, &excepinfo, NULL);
1204 ok(hr == DISP_E_EXCEPTION, "IDispatch_Invoke should have returned DISP_E_EXCEPTION instead of 0x%08x\n", hr);
1205 ok(excepinfo.wCode == 0x0 && excepinfo.scode == E_NOTIMPL,
1206 "EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
1207 excepinfo.wCode, excepinfo.scode);
1208 VariantClear(&varresult);
1211 pTypeInfo = NonOleAutomation_GetTypeInfo();
1212 dispparams.cNamedArgs = 0;
1213 dispparams.cArgs = 0;
1214 dispparams.rgdispidNamedArgs = NULL;
1215 dispparams.rgvarg = NULL;
1216 VariantInit(&varresult);
1217 hr = ITypeInfo_Invoke(pTypeInfo, &NonOleAutomation, DISPID_NOA_BSTRRET, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
1218 ok_ole_success(hr, ITypeInfo_Invoke);
1219 ok(V_VT(&varresult) == VT_BSTR, "V_VT(&varresult) should be VT_BSTR instead of %d\n", V_VT(&varresult));
1220 ok(V_BSTR(&varresult) != NULL, "V_BSTR(&varresult) should not be NULL\n");
1222 VariantClear(&varresult);
1223 ITypeInfo_Release(pTypeInfo);
1225 /* tests call put_Name without named arg */
1226 VariantInit(&vararg[0]);
1227 dispparams.cNamedArgs = 0;
1228 dispparams.rgdispidNamedArgs = NULL;
1229 dispparams.cArgs = 1;
1230 dispparams.rgvarg = vararg;
1231 VariantInit(&varresult);
1232 hr = IDispatch_Invoke(pDispatch, DISPID_TM_NAME, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYPUT, &dispparams, &varresult, &excepinfo, NULL);
1233 ok(hr == DISP_E_PARAMNOTFOUND, "IDispatch_Invoke should have returned DISP_E_PARAMNOTFOUND instead of 0x%08x\n", hr);
1234 VariantClear(&varresult);
1236 /* tests param type that cannot be coerced */
1237 VariantInit(&vararg[0]);
1238 V_VT(&vararg[0]) = VT_UNKNOWN;
1239 V_UNKNOWN(&vararg[0]) = NULL;
1240 dispparams.cNamedArgs = 1;
1241 dispparams.rgdispidNamedArgs = &dispidNamed;
1242 dispparams.cArgs = 1;
1243 dispparams.rgvarg = vararg;
1244 VariantInit(&varresult);
1245 #if 0 /* NULL unknown not currently marshaled correctly */
1246 hr = IDispatch_Invoke(pDispatch, DISPID_TM_NAME, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYPUT, &dispparams, &varresult, &excepinfo, NULL);
1247 ok(hr == DISP_E_TYPEMISMATCH, "IDispatch_Invoke should have returned DISP_E_TYPEMISMATCH instead of 0x%08x\n", hr);
1249 VariantClear(&varresult);
1251 /* tests bad param type */
1252 VariantInit(&vararg[0]);
1253 V_VT(&vararg[0]) = VT_CLSID;
1254 V_BYREF(&vararg[0]) = NULL;
1255 dispparams.cNamedArgs = 1;
1256 dispparams.rgdispidNamedArgs = &dispidNamed;
1257 dispparams.cArgs = 1;
1258 dispparams.rgvarg = vararg;
1259 VariantInit(&varresult);
1260 hr = IDispatch_Invoke(pDispatch, DISPID_TM_NAME, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYPUT, &dispparams, &varresult, &excepinfo, NULL);
1261 ok(hr == DISP_E_BADVARTYPE, "IDispatch_Invoke should have returned DISP_E_BADVARTYPE instead of 0x%08x\n", hr);
1262 VariantClear(&varresult);
1264 /* tests too small param count */
1265 dispparams.cNamedArgs = 0;
1266 dispparams.rgdispidNamedArgs = NULL;
1267 dispparams.cArgs = 0;
1268 dispparams.rgvarg = NULL;
1269 VariantInit(&varresult);
1270 hr = IDispatch_Invoke(pDispatch, DISPID_TM_DOSOMETHING, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
1271 ok(hr == DISP_E_BADPARAMCOUNT, "IDispatch_Invoke should have returned DISP_E_BADPARAMCOUNT instead of 0x%08x\n", hr);
1272 VariantClear(&varresult);
1274 /* tests propget function with large param count */
1275 VariantInit(&vararg[0]);
1276 V_VT(&vararg[0]) = VT_BSTR;
1277 V_BSTR(&vararg[0]) = NULL;
1278 V_VT(&vararg[1]) = VT_I4;
1279 V_I4(&vararg[1]) = 1;
1280 dispparams.cNamedArgs = 0;
1281 dispparams.cArgs = 2;
1282 dispparams.rgdispidNamedArgs = NULL;
1283 dispparams.rgvarg = vararg;
1284 hr = IDispatch_Invoke(pDispatch, DISPID_TM_STATE, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
1285 ok(hr == DISP_E_NOTACOLLECTION, "IDispatch_Invoke should have returned DISP_E_NOTACOLLECTION instead of 0x%08x\n", hr);
1287 IDispatch_Release(pDispatch);
1288 IWidget_Release(pWidget);
1290 trace("calling end_host_object\n");
1291 end_host_object(tid, thread);
1294 static void test_DispCallFunc(void)
1296 static const WCHAR szEmpty[] = { 0 };
1297 VARTYPE rgvt[] = { VT_R8, VT_BSTR, VT_BSTR, VT_VARIANT|VT_BYREF };
1298 VARIANTARG vararg[4];
1300 VARIANTARG *rgpvarg[4] = { &vararg[0], &vararg[1], &vararg[2], &vararg[3] };
1301 VARIANTARG varresult;
1303 IWidget *pWidget = Widget_Create();
1304 V_VT(&vararg[0]) = VT_R8;
1305 V_R8(&vararg[0]) = 3.141;
1306 V_VT(&vararg[1]) = VT_BSTR;
1307 V_BSTR(&vararg[1]) = SysAllocString(szEmpty);
1308 V_VT(&vararg[2]) = VT_BSTR;
1309 V_BSTR(&vararg[2]) = SysAllocString(szEmpty);
1310 V_VT(&vararg[3]) = VT_VARIANT|VT_BYREF;
1311 V_VARIANTREF(&vararg[3]) = &varref;
1312 V_VT(&varref) = VT_ERROR;
1313 V_ERROR(&varref) = DISP_E_PARAMNOTFOUND;
1314 VariantInit(&varresult);
1315 hr = DispCallFunc(pWidget, 36, CC_STDCALL, VT_UI4, 4, rgvt, rgpvarg, &varresult);
1316 ok_ole_success(hr, DispCallFunc);
1317 VariantClear(&varresult);
1318 VariantClear(&vararg[1]);
1319 VariantClear(&vararg[2]);
1320 IWidget_Release(pWidget);
1323 static void test_StaticWidget(void)
1325 ITypeInfo *type_info;
1326 DISPPARAMS dispparams;
1327 VARIANTARG vararg[4];
1328 EXCEPINFO excepinfo;
1332 type_info = get_type_info(&IID_IStaticWidget);
1335 dispparams.cNamedArgs = 0;
1336 dispparams.cArgs = 1;
1337 dispparams.rgdispidNamedArgs = NULL;
1338 dispparams.rgvarg = vararg;
1339 V_VT(vararg) = VT_DISPATCH;
1340 V_DISPATCH(vararg) = (IDispatch*)&TestDualDisp;
1341 VariantInit(&varresult);
1342 hr = ITypeInfo_Invoke(type_info, &StaticWidget, DISPID_TM_TESTDUAL, DISPATCH_METHOD,
1343 &dispparams, &varresult, &excepinfo, NULL);
1344 ok_ole_success(hr, IDispatch_Invoke);
1345 ok(V_VT(&varresult) == VT_EMPTY, "vt %x\n", V_VT(&varresult));
1346 VariantClear(&varresult);
1348 ITypeInfo_Release(type_info);
1351 START_TEST(tmarshal)
1355 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
1357 hr = register_current_module_typelib();
1358 ok_ole_success(hr, register_current_module_typelib);
1360 test_typelibmarshal();
1361 test_DispCallFunc();
1362 test_StaticWidget();
1364 hr = UnRegisterTypeLib(&LIBID_TestTypelib, 1, 0, LOCALE_NEUTRAL, 1);
1365 ok_ole_success(hr, UnRegisterTypeLib);