Article ID: 200292
Article Last Modified on 10/24/2003
HRESULT hr = CoCreateInstance(..., ..., IID_IUnknown, (LPVOID*)&pUnk);
if (FAILED(hr))
//Do error handling.
hr = OleRun(pUnk);
if (FAILED(hr)) {
pUnk->Release();
//Do error handling
}
// Query for the required interface, such as IFoo.
hr = pUnk->QueryInterface( IID_IFoo, pFoo);
if (FAILED(hr)) {
pUnk->Release();
//Do error handling
}
// Declare the smart pointer for the IFoo interface. IFooPtr m_pFoo; // Attach the raw interface pointer which you got above // to the smart pointer wrapper. m_pFoo.Attach(pFoo);
Additional query words: Smart pointers
Keywords: kbbug kbfix kbvc600fix KB200292