[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1727
  • Last Modified:

Read and write ini file in PPC

Experts

I am using embedded visual C++ 4.0.
i want to use a ini file to store the setting of my program in PPC. How can i do it?

Many thanks!
0
smallee
Asked:
smallee
1 Solution
 
ho_alanCommented:
try this
se the CIniFile class
http://www.pocketpcdn.com/articles/samples/IniEdit.zip

The CIniFile Class
Ini files are managed by objects of the CIniFile class (see sample code). Information is serialized on a standard Unicode text file (Unicode header is required) and has the following general format:


[Section]
Entry=Value


Sections are unique on an ini file and entries are unique in a section. Both section and entry names are case sensitive. The value can be any string up to the end of line. There is no limit on the size of strings. No comments are supported on this version.

Objects are created through the constructor CIniFile::CIniFile(LPCTSTR pszFile = NULL). If you supply a file name onthe constructor, the file will be loaded immediately. Otherwise, you can load it by calling BOOL CIniFile::Load(LPCTSTR pszFile = NULL). When you are done using the ini file, you can call BOOL CIniFile::Save(LPCTSTR pszFile = NULL) filling in the file name if the file was not loaded or created empty. If the file was loaded or created with a name, the destructor will save it for you.

Setting and retrieving values is achieved through the Get and Set family methods. These have a consistent signature:


BOOL Get(LPCTSTR pszSection, LPCTSTR pszEntry, CString &strValue);
BOOL Set(LPCTSTR pszSection, LPCTSTR pszEntry, const CString &strValue);


You have to provide the section name, entry name and the value as the last argument. These methods can be extended to support any type you require. In this implementation, I provide two other types just to illustrate the implementation.


BOOL Get(LPCTSTR pszSection, LPCTSTR pszEntry, int &nVal);
BOOL Set(LPCTSTR pszSection, LPCTSTR pszEntry, int nVal);
BOOL Set(LPCTSTR pszSection, LPCTSTR pszEntry, COLORREF rgb);
BOOL Get(LPCTSTR pszSection, LPCTSTR pszEntry, COLORREF &rgb);


Please study their implementations before implementing your own types.

All methods return a BOOL value that reflects the success status of the operation. The Set methods will create both section and entry if these do not exist. Once again, remember about case sensitivity!

0
 
ee_ai_constructCommented:
Question close reversed.   Point passing.
500 Points Forfeit

ai, cs admin
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now