@@ -89,6 +89,23 @@ struct VariantMarshalTest
89
89
}
90
90
};
91
91
92
+ class InterfaceImpl :
93
+ public UnknownImpl,
94
+ public IInterface2
95
+ {
96
+ public: // IInterface1
97
+ public: // IInterface2
98
+ public: // IUnknown
99
+ STDMETHOD (QueryInterface)(
100
+ /* [in] */ REFIID riid,
101
+ /* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppvObject)
102
+ {
103
+ return DoQueryInterface (riid, ppvObject, static_cast <IInterface1 *>(this ), static_cast <IInterface2 *>(this ));
104
+ }
105
+
106
+ DEFINE_REF_COUNTING ();
107
+ };
108
+
92
109
void ValidationTests ()
93
110
{
94
111
::printf (__FUNCTION__ " () through CoCreateInstance...\n " );
@@ -334,30 +351,11 @@ void ValidationTests()
334
351
335
352
::printf (" -- Interfaces...\n " );
336
353
{
337
- struct InterfaceImpl : IInterface2
338
- {
339
- STDMETHOD (QueryInterface)(REFIID riid, void ** ppvObject) override
340
- {
341
- if (riid == __uuidof (IInterface1) || riid == __uuidof (IInterface2))
342
- {
343
- *ppvObject = static_cast <IInterface2*>(this );
344
- }
345
- else if (riid == __uuidof (IUnknown))
346
- {
347
- *ppvObject = static_cast <IUnknown*>(this );
348
- }
349
- else
350
- {
351
- *ppvObject = nullptr ;
352
- return E_NOINTERFACE;
353
- }
354
- return S_OK;
355
- }
356
- STDMETHOD_ (ULONG, AddRef)() override { return 1 ; }
357
- STDMETHOD_ (ULONG, Release)() override { return 1 ; }
358
- } iface{};
354
+ ComSmartPtr<InterfaceImpl> iface;
355
+ iface.Attach (new InterfaceImpl ());
356
+
359
357
ComSmartPtr<IInterface2> result;
360
- HRESULT hr = miscTypesTesting->Marshal_Interface (& iface, &result);
358
+ HRESULT hr = miscTypesTesting->Marshal_Interface (iface, &result);
361
359
THROW_IF_FAILED (hr);
362
360
}
363
361
}
0 commit comments