Use QueryInterface Example (C++ COM)
This example shows how to use QueryInterface.
LPUNKNOWN iUnk = NULL;
LPFEATURE m_Feature = NULL;
HRESULT hres = S_FALSE;
...
// Get the underlying object
hres = m_Feature->IGetSpecificFeature(
&iUnk );
LPREFPLANE m_RefPlane = NULL;
hres = iUnk->QueryInterface(
IID_IRefPlane, (LPVOID*)&m_RefPlane);
// If Feature is a RefPlane
if (hres == S_OK && m_RefPlane
!= NULL)
{
AfxMessageBox( _T("This feature is a reference plane") );
// Use m_RefPlane object
...
// Release m_RefPlane object
m_RefPlane->Release();
}
// Release iUnk object
iUnk->Release();
*/