Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

INI-File Controls, with pure API

0.00/5 (No votes)
16 Feb 2006 1  
Control the ini file very detail ( Session, Key, Key Value)

Introduction

hi, This description is Ini file control, Sharing code with others is a great way to not only help others, but also to become a better programmer. With many thousands of people downloading your code you will not only get a lot of positive feedback, but also bug fixes, free testing, and more often than not, suggestions on how to make the code even better. It also encourages others to share their code, which in turn gives you access to an even larger base of free source code.

So Sorry !!

[Modified: -explain]

I made CXIniFiles class, this class control(, Key and section , key value, add, delete, modify) INI-file. and inform(total number of section, number of key etc) ini-file.

CXIniFiles Class like this:

class CXIniFiles 
{
private:

 BOOL IsDataChanged;  // Handle of Current IniFile
 CString IniPath;          // Ini File  full path
  

 struct XSection  //Struct of  Inifile
 {
  CString SectionName;
  CArray<CString ,CString > Keys;
  CArray<CString ,CString > Values;
 };

 

 CArray<XSection,XSection> Sections;

 CString LegalString(CString path);
 int AddSection(CString sectionname);
 int AddSection(CStringArray mKeys,CStringArray mValues,CString sectionname);
 void SetPath(CString path);

public:

 //Construction & destruction

CXIniFiles();
 virtual ~CXIniFiles();

 BOOL Open(CString path);
 void Reset();
 void Close();
 void DoNotWrite();
 BOOL Write();

 int GetSectionIndex(CString sectionname);
 int GetSection(CStringArray &mKeys,CStringArray &mValues,CString sectionname);
 int GetSetionsSize(){return Sections.GetSize();}
 int GetKeyIndex(int sectionIndex,CString keyname);
 int GetKeysSize(CString sectionname);

 CString GetSection(int sectionIndex);
 CString GetKeyName(int sectionIndex, int keyIndex);
 CString GetKeyValue(CString sctionname,CString keyname);

 int DeleteSection(CString strsectionname);
 int AddKey(CString sectionname,CString keyname,CString value);
 int DeleteKey(CString sectionname,CString delkey);
 
 BOOL IsSection(CString sectionname);
 BOOL IsKey(CString sectionname ,  CString keyname);

 int SetKeyValue(CString sectionname,CString keyname,CString value); 
 int SetSectionValue(CString oldname,CString newname);
};

Very Simple Constructure!!!

Set and Get , and Is , ADD, DELETE real control method

Have a Nice Day and a Beautiful Life!!!

Do U Have a any Question, Send Mail plz.

 

 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here