OSDN Git Service

・ MBCS->Unicode対応
[seraphyscrtools/SeraphyScriptTools.git] / PrivateProfile.cpp
index 95908c3..4e1ba03 100644 (file)
@@ -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<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;
 }