|
1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #include <afxwin.h> |
|
23 |
|
24 #include "INI.h" |
|
25 #include <afxcoll.h> |
|
26 |
|
27 #ifdef _DEBUG |
|
28 #undef THIS_FILE |
|
29 static char THIS_FILE[]=__FILE__; |
|
30 #define new DEBUG_NEW |
|
31 #endif |
|
32 |
|
33 |
|
34 CStatIniFile::CStatIniFile() |
|
35 { |
|
36 } |
|
37 |
|
38 CStatIniFile::~CStatIniFile() |
|
39 { |
|
40 } |
|
41 |
|
42 // return an empty string if section or key does not exist |
|
43 CString CStatIniFile::GetKeyValue(const CString& strKey,const CString& strSection) const |
|
44 { |
|
45 TCHAR result[255]; |
|
46 GetPrivateProfileString((LPCTSTR)strSection,(LPCTSTR)strKey,_T( ""),result, 255, (LPCTSTR)istrIniFileName); |
|
47 CString strResult(result); |
|
48 return strResult; |
|
49 } |
|
50 |
|
51 |
|
52 BOOL CStatIniFile::WriteKey(const CString& strValue, const CString& strKey, const CString& strSection) const |
|
53 { |
|
54 return WritePrivateProfileString (strSection, strKey, strValue, istrIniFileName); |
|
55 |
|
56 } |
|
57 BOOL CStatIniFile::DeleteSection(const CString& strSection) const |
|
58 { |
|
59 return WritePrivateProfileString(strSection,NULL,NULL,istrIniFileName); |
|
60 } |
|
61 |
|
62 BOOL CStatIniFile::SectionExists(const CString& strSection) const |
|
63 { |
|
64 TCHAR result[255]; |
|
65 long lRetValue = GetPrivateProfileString((LPCTSTR)strSection,NULL,_T( ""),result, 255, (LPCTSTR)istrIniFileName); |
|
66 return (lRetValue > 0); //true if section exists |
|
67 } |
|
68 |
|
69 void CStatIniFile::SetIniFileName(const CString& strName) |
|
70 { |
|
71 istrIniFileName = strName; |
|
72 } |