/////////////////////////////////////////////////////////////////////////////
// CPrivateProfile
-STDMETHODIMP CPrivateProfile::InterfaceSupportsErrorInfo(REFIID riid)
-{
- static const IID* arr[] =
- {
- &IID_IPrivateProfile
- };
- for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
- {
- if (IsEqualGUID(*arr[i],riid))
- return S_OK;
- }
- return S_FALSE;
-}
-
STDMETHODIMP CPrivateProfile::get_ProfilePath(BSTR *pVal)
{
return m_bstr_profilepath.CopyTo(pVal);
return S_OK;
}
-STDMETHODIMP CPrivateProfile::OpenSection(VARIANT text,VARIANT* pVal)
+STDMETHODIMP CPrivateProfile::OpenSection(VARIANT text, VARIANT* pVal)
{
::VariantInit(pVal);
CComVariant varText;
- if(varText.ChangeType(VT_BSTR,&text) != S_OK){
- return DISP_E_TYPEMISMATCH;
+
+ HRESULT hr;
+ if (FAILED(hr = varText.ChangeType(VT_BSTR, &text))) {
+ return hr;
}
+
if (m_bstr_profilepath.Length() <= 0) {
- ErrorInfo(IDS_ERR_PROFILEPATH);
- return DISP_E_EXCEPTION;
+ return Error(IDS_ERR_PROFILEPATH);
}
+
CComObject<CProfileSection>* pSection = NULL;
- pSection->CreateInstance(&pSection);
+ if (FAILED(hr = CComObject<CProfileSection>::CreateInstance(&pSection))) {
+ return hr;
+ }
ATLASSERT(pSection);
pSection->m_szProfilePath = m_bstr_profilepath;
pSection->m_szSectionName = varText.bstrVal;
IUnknown* pUnk = NULL;
- pSection->QueryInterface(IID_IUnknown,(void**)&pUnk);
+ if (FAILED(hr = pSection->QueryInterface(IID_IUnknown, (void**)&pUnk))) {
+ return hr;
+ }
ATLASSERT(pUnk);
- pVal->vt = VT_UNKNOWN;
+
+ pVal->vt = VT_UNKNOWN;
pVal->punkVal = pUnk;
return S_OK;
}