X-Git-Url: http://git.osdn.net/view?p=seraphyscrtools%2FSeraphyScriptTools.git;a=blobdiff_plain;f=PrivateProfile.cpp;fp=PrivateProfile.cpp;h=4e1ba031fd0a92257aaef83d5ce0577b571058b7;hp=95908c37d99a726f2ca761d59f0208965a8c7f6d;hb=82de408e53d9aef7ad24c955f28641eb7facb08c;hpb=31b7fd93b6ea8ccc4d7f091f92cc1b1227bcb077 diff --git a/PrivateProfile.cpp b/PrivateProfile.cpp index 95908c3..4e1ba03 100644 --- a/PrivateProfile.cpp +++ b/PrivateProfile.cpp @@ -8,20 +8,6 @@ ///////////////////////////////////////////////////////////////////////////// // 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); @@ -33,28 +19,36 @@ STDMETHODIMP CPrivateProfile::put_ProfilePath(BSTR newVal) 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* pSection = NULL; - pSection->CreateInstance(&pSection); + if (FAILED(hr = CComObject::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; }