}
ATLASSERT(pSection);
- pSection->m_szProfilePath = m_bstr_profilepath;
- pSection->m_szSectionName = varText.bstrVal;
-
- IUnknown* pUnk = NULL;
- if (FAILED(hr = pSection->QueryInterface(IID_IUnknown, (void**)&pUnk))) {
+ CComPtr<IUnknown> pUnk = NULL;
+ if (FAILED(hr = pSection->QueryInterface(&pUnk))) {
+ delete pSection;
return hr;
}
ATLASSERT(pUnk);
+ pSection->m_szProfilePath = m_bstr_profilepath;
+ pSection->m_szSectionName = varText.bstrVal;
+
pVal->vt = VT_UNKNOWN;
- pVal->punkVal = pUnk;
+ pVal->punkVal = pUnk.Detach();
return S_OK;
}