OSDN Git Service

セットアップの追加、ヘルプの修正
[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::get_ProfilePath(BSTR *pVal)
12 {
13         return m_bstr_profilepath.CopyTo(pVal);
14 }
15
16 STDMETHODIMP CPrivateProfile::put_ProfilePath(BSTR newVal)
17 {
18         m_bstr_profilepath = newVal;
19         return S_OK;
20 }
21
22 STDMETHODIMP CPrivateProfile::OpenSection(VARIANT text, VARIANT* pVal)
23 {
24         ::VariantInit(pVal);
25         CComVariant varText;
26
27         HRESULT hr;
28         if (FAILED(hr = varText.ChangeType(VT_BSTR, &text))) {
29                 return hr;
30         }
31
32         if (m_bstr_profilepath.Length() <= 0) {
33                 return Error(IDS_ERR_PROFILEPATH);
34         }
35
36         CComObject<CProfileSection>* pSection = NULL;
37         if (FAILED(hr = CComObject<CProfileSection>::CreateInstance(&pSection))) {
38                 return hr;
39         }
40         ATLASSERT(pSection);
41
42         CComPtr<IUnknown> pUnk = NULL;
43         if (FAILED(hr = pSection->QueryInterface(&pUnk))) {
44                 delete pSection;
45                 return hr;
46         }
47         ATLASSERT(pUnk);
48
49         pSection->m_szProfilePath = m_bstr_profilepath;
50         pSection->m_szSectionName = varText.bstrVal;
51
52         pVal->vt = VT_UNKNOWN;
53         pVal->punkVal = pUnk.Detach();
54         return S_OK;
55 }