| CComPtr<IMyInterface> spMyInterface; spMyInterface.CoCreateInstance(); //register interface in global interface table CComPtr<IGlobalInterfaceTable> spGIT; spGIT.CoCreateInstance(CLSID_StdGlobalInterfaceTable); if (spGIT) { spGIT->RegisterInterfaceInGlobal(spMyInterface, IID_IMyInterface, &m_dwCookie); } |
| CComPtr<IMyInterface> spMyInterface; if (m_dwCookie!=0) { CComPtr<IGlobalInterfaceTable> spGIT; spGIT.CoCreateInstance(CLSID_StdGlobalInterfaceTable); if (spGIT) { spGIT->GetInterfaceFromGlobal(m_dwCookie, IID_IMyInterface, (void**)&spMyInterface.p); } } if (spMyInterface) { //Call my interface } |
| if (m_dwCookie!=0) { CComPtr<IGlobalInterfaceTable> spGIT; spGIT.CoCreateInstance(CLSID_StdGlobalInterfaceTable); if (spGIT) { spGIT->RevokeInterfaceFromGlobal(m_dwCookie); m_dwCookie = 0; } } |