OSDN Git Service

20021009版ソース
[seraphyscrtools/SeraphyScriptTools.git] / PrivateProfile.cpp
1 // PrivateProfile.cpp : CPrivateProfile \82Ì\83C\83\93\83v\83\8a\83\81\83\93\83e\81[\83V\83\87\83\93
2 #include "stdafx.h"
3 #include "SeraphyScriptTools.h"
4 #include "PrivateProfile.h"
5 #include "profilesection.h"
6 #include "generic.h"
7
8 /////////////////////////////////////////////////////////////////////////////
9 // CPrivateProfile
10
11 STDMETHODIMP CPrivateProfile::InterfaceSupportsErrorInfo(REFIID riid)
12 {
13         static const IID* arr[] = 
14         {
15                 &IID_IPrivateProfile
16         };
17         for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
18         {
19                 if (IsEqualGUID(*arr[i],riid))
20                         return S_OK;
21         }
22         return S_FALSE;
23 }
24
25 STDMETHODIMP CPrivateProfile::get_ProfilePath(BSTR *pVal)
26 {
27         *pVal = m_bstr_profilepath.copy();
28         return S_OK;
29 }
30
31 STDMETHODIMP CPrivateProfile::put_ProfilePath(BSTR newVal)
32 {
33         m_bstr_profilepath = newVal;
34         return S_OK;
35 }
36
37 STDMETHODIMP CPrivateProfile::OpenSection(VARIANT text,VARIANT* pVal)
38 {
39         ::VariantInit(pVal);
40         CComVariant varText;
41         if(varText.ChangeType(VT_BSTR,&text) != S_OK){
42                 return DISP_E_TYPEMISMATCH;
43         }
44         if(m_bstr_profilepath.length() <= 0){
45                 ErrorInfo(IDS_ERR_PROFILEPATH);
46                 return DISP_E_EXCEPTION;
47         }
48         CComObject<CProfileSection>* pSection = NULL;
49         pSection->CreateInstance(&pSection);
50         ATLASSERT(pSection);
51         WideCharToMultiByte(GetACP(),0,m_bstr_profilepath,-1,pSection->m_szProfilePath,MAX_PATH,NULL,NULL);
52         WideCharToMultiByte(GetACP(),0,varText.bstrVal   ,-1,pSection->m_szSectionName,MAX_PATH,NULL,NULL);
53         IUnknown* pUnk = NULL;
54         pSection->QueryInterface(IID_IUnknown,(void**)&pUnk);
55         ATLASSERT(pUnk);
56         pVal->vt      = VT_UNKNOWN;
57         pVal->punkVal = pUnk;
58         return S_OK;
59 }