Banner
CINIFile
What does CINIFile do?
IconIt is a class written in C++ for MFC that allows programmers to easily create and read INI configuration files. It allows saving in string (CString) format, integer format, and float/double format. It however, does not support writing of comments in the file. To be honest, I think comments in a INI file are a waste of time so I couldn't be bothered writing support for them. The class will parse them fine, but not store them.
Download

CINIFile
The ZIP file that contains the class, readme, and a class on which it depends for some of its functions called CConversion.
Version: v1.0.0
Size: 10KB
Download: Here

 

Requirements

The class was written in Visual C++ 2002 (MFC) so you will probably need at least that. I have not tested it on anything less.

Version History

Version 1.0.0

  • First release to the public!
Help

The main code help (MSDN style) is here. It thoroughly documents all aspects of the class.

 

Here are some code snippets that shows you how to basically use the class:

 

Writing to an INI File

CINIFile INIFile(m_strAppPath + "Options.ini");
BOOL bRetVal;
int nKeyIndex;

 

nKeyIndex = INIFile.AddKey("Test Key");

 

INIFile.AddValue(nKeyIndex, "Test CString", "Test Data YEAH");
INIFile.AddValue(nKeyIndex, "Test Double", 0.0115214);
INIFile.AddValue(nKeyIndex, "Test Integer", 5);

 

bRetVal = INIFile.WriteINIFile();

 

 

Reading from an INI File

CINIFile INIFile(m_strAppPath + "Options.ini");
BOOL bRetVal;
int nKeyIndex;
int nKeyIndex2;
double dtest;
CString strTest;
int nTest;

 

bRetVal = INIFile.ReadINIFile();

 

nKeyIndex = INIFile.GetKeyIndex("Test Key");

 

INIFile.ReadValue(nKeyIndex, "Test Double", dtest);
INIFile.ReadValue(nKeyIndex, "Test CString", strTest);
INIFile.ReadValue(nKeyIndex, "Test Integer", nTest);

Additional Help/Bug Reports/Forums

If you have problems using the class or have some bugs please email me. See the Contact page.

Alternately you could ask on the forums:

 

[Code Snippets Forum]