|
Clearly and easily to understand, thanks a lot!
|
|
|
|
|
one star removed ... use of MFC
|
|
|
|
|
Try to keep this entry ini file and then try to read section COR , against key VALUE. it would not read the whole data
Any idea why does that happen?
[COR]
VALUE=abcdef|77060,abcdef|77061,abcdef|77062,abcdef|77063,abcdef|77064,abcdef|43913,abcdef|77065,abcdef|77184,abcdef|77185,abcdef|77186,abcdef|77187,abcdef|77188,abcdef|77189,abcdef|77190,abcdef|77191,abcdef|77192,abcdef|77193,abcdef|77194,abcdef|77195,abcdef|77196,abcdef|77197,abcdef|77198,abcdef|77199,abcdef|77200,abcdef|77201,abcdef|77202,abcdef|77203,abcdef|77204,abcdef|77205,abcdef|77206,abcdef|77207,abcdef|77208,abcdef|77209,abcdef|77210,abcdef|77211,abcdef|77212,abcdef|77213,abcdef|77214,abcdef|77215,abcdef|77216,abcdef|77217,abcdef|77218,abcdef|77219,abcdef|77220,abcdef|77221,abcdef|77222,abcdef|77223,abcdef|77224,abcdef|77225,abcdef|77226,abcdef|77227,abcdef|77228,abcdef|77229,abcdef|77230,abcdef|77231,abcdef|77232,abcdef|77233,abcdef|77234,abcdef|77235,abcdef|77236,abcdef|77237,abcdef|77238,abcdef|77239,abcdef|77240,abcdef|77241,abcdef|77242,abcdef|77243,abcdef|77244,abcdef|77245,abcdef|77246,abcdef|77247,abcdef|77248,abcdef|77249,abcdef|77250,abcdef|77251,abcdef|77252,abcdef|77253,abcdef|77254,abcdef|77255,abcdef|77256,abcdef|77257,abcdef|77258,abcdef|77259,abcdef|77260,abcdef|77261,abcdef|77262,abcdef|77263,abcdef|77266,abcdef|77267,abcdef|77268,abcdef|77269,abcdef|77270,abcdef|77271,abcdef|77272,abcdef|77273,abcdef|77274,abcdef|77275,abcdef|77276,abcdef|77277,abcdef|77278,abcdef|77279,abcdef|77280,abcdef|77281,abcdef|77282,abcdef|77283,abcdef|77284,abcdef|77285,abcdef|77286,abcdef|77287,abcdef|77288,abcdef|77289,abcdef|77290,abcdef|77291,abcdef|77292,abcdef|77293,abcdef|77294,abcdef|77295,abcdef|77296,abcdef|77297,abcdef|77298,abcdef|77299,abcdef|77300,abcdef|77301,abcdef|77302,abcdef|77303,abcdef|77304,abcdef|77305,abcdef|77306,abcdef|77307,abcdef|77308,abcdef|77309,abcdef|77310,abcdef|77311,abcdef|77312,abcdef|77313,abcdef|77314,abcdef|77315,abcdef|77316,abcdef|77317,abcdef|77318,abcdef|77319,abcdef|77320,abcdef|77321,abcdef|77322,abcdef|77323,abcdef|77324,abcdef|77325,abcdef|77326,abcdef|77327,abcdef|77328,abcdef|77329,abcdef|77330,abcdef|77331,abcdef|77332,abcdef|77333,abcdef|77334,abcdef|77335,abcdef|77336,abcdef|77337,abcdef|77338,abcdef|77339,abcdef|77340,abcdef|77341,abcdef|77342,abcdef|77343,abcdef|77344,abcdef|77345,abcdef|77346,abcdef|77347,abcdef|77432,abcdef|77433,abcdef|77434,abcdef|77435,abcdef|77436,abcdef|77437,abcdef|77438,abcdef|77439,abcdef|77440,abcdef|77441,abcdef|77442,abcdef|77443,abcdef|77444,abcdef|77445,abcdef|77446,abcdef|77447,abcdef|77448,abcdef|77449,abcdef|77450,abcdef|77451,abcdef|77452,abcdef|77453,abcdef|77454,abcdef|77455,abcdef|77456,abcdef|77457,abcdef|77458,abcdef|77459,abcdef|77460,abcdef|77461,abcdef|77462,abcdef|77463,abcdef|77464,abcdef|77465,abcdef|77466,abcdef|77467,abcdef|77468,abcdef|77469,abcdef|77470,abcdef|77471,abcdef|77472,abcdef|77473,abcdef|77474,abcdef|77475,abcdef|77476,abcdef|77477,abcdef|77478,abcdef|77479,abcdef|77480,abcdef|77481,abcdef|77482,abcdef|77483,abcdef|77484,abcdef|77485,abcdef|77486,abcdef|77487,abcdef|77488,abcdef|77489,abcdef|77490,abcdef|77491,abcdef|41582,abcdef|41583,abcdef|41584,abcdef|41589,abcdef|41593,abcdef|41594,abcdef|41620,abcdef|41624,abcdef|37836,abcdef|37837,abcdef|40252,abcdef|40253,abcdef|36046,abcdef|36047,abcdef|36048,abcdef|36049,abcdef|36064,abcdef|36065,abcdef|36087,abcdef|36088,abcdef|36126,abcdef|36127,abcdef|40561,abcdef|40562,abcdef|40637,abcdef|40638,abcdef|40645,abcdef|40646,abcdef|40647,abcdef|40648,abcdef|40659,abcdef|40661,abcdef|40662,abcdef|40663,abcdef|40676,abcdef|40677,abcdef|40678,abcdef|40679,abcdef|36546,abcdef|36547,abcdef|36550,abcdef|36551,abcdef|36552,abcdef|36556,abcdef|36557,abcdef|36558,abcdef|36560,abcdef|36561,abcdef|36562,abcdef|36563,abcdef|36564,abcdef|36565,abcdef|36566,abcdef|36567,abcdef|36568,abcdef|36569,abcdef|36570,abcdef|36571,abcdef|36573,abcdef|36576,abcdef|40956,abcdef|40957,abcdef|40959,abcdef|40960,abcdef|39829,abcdef|39830,abcdef|35000,abcdef|35001,abcdef|35004,abcdef|35005,abcdef|35428,abcdef|35429,abcdef|77492,abcdef|77493,abcdef|77494,abcdef|77495,abcdef|77496,abcdef|77497,abcdef|77498,abcdef|77499,abcdef|77500,abcdef|77501,abcdef|77502,abcdef|77503,abcdef|77504,abcdef|77505,abcdef|77506,abcdef|77507,abcdef|77508,abcdef|77509,abcdef|77510,abcdef|77511,abcdef|77512,abcdef|77513,abcdef|77514,abcdef|77515,abcdef|77516,abcdef|77517,abcdef|77518,abcdef|77519,abcdef|77520,abcdef|77521,abcdef|77522,abcdef|77523,abcdef|77524,abcdef|77525,abcdef|77526,abcdef|77527,abcdef|77528,abcdef|77529,abcdef|77530,abcdef|77531
deeps1985
|
|
|
|
|
I updated two enumeration function to increase its speed performance and no limitation on data count.
MSDN: Help on GetPrivateProfileString Function:
Return Value: If either lpAppName or lpKeyName is NULL and the supplied destination buffer is too small to hold all the strings, the last string is truncated and followed by two null characters. In this case, the return value is equal to nSize minus two.
int CIniFile::GetSectionNames( CStringList* plistSectionNames )
{
int nSize = 1000;
long lRetValue = 0;
TCHAR* pacReturnData = NULL;
plistSectionNames->RemoveAll();
do
{
delete [] pacReturnData;
nSize *= 2;
pacReturnData = new TCHAR[nSize];
lRetValue = GetPrivateProfileSectionNames(pacReturnData, nSize, (LPCTSTR)m_strINiFileName);
}
while(lRetValue>=(nSize-2));
TCHAR* pKey = pacReturnData;
while( *pKey )
{
CString strData(pKey);
if(!strData.IsEmpty())
plistSectionNames->InsertAfter(plistSectionNames->GetTailPosition(), strData);
pKey += strlen( pKey ) + 1;
}
delete [] pacReturnData;
return plistSectionNames->GetCount();
}
int CIniFile::GetSectionData( CString strSection, CStringList* plistSectionData )
{
int nSize = 1000;
long lRetValue = 0;
TCHAR* pacReturnData = NULL;
plistSectionData->RemoveAll();
do
{
delete [] pacReturnData;
nSize *= 2;
pacReturnData = new TCHAR[nSize];
lRetValue = GetPrivateProfileSection((LPCTSTR)strSection, pacReturnData, nSize, (LPCTSTR)m_strINiFileName);
}
while(lRetValue>=(nSize-2));
TCHAR* pKey = pacReturnData;
while( *pKey )
{
CString strData(pKey);
if(!strData.IsEmpty())
plistSectionData->InsertAfter(plistSectionData->GetTailPosition(), strData);
pKey += strlen( pKey ) + 1;
}
delete [] pacReturnData;
return plistSectionData->GetCount();
}
modified on Saturday, November 6, 2010 10:07 AM
|
|
|
|
|
Hi,
Can anyone explain me how can I know keys count in ini file?
I created ini file which has only one section.
In that section, I have several keys.
I would like to know keys count in that section,
to proceed loop for other programs.
Could anyone tell me API or some codes to know keys count
of ini file.
Thanks in advance.
|
|
|
|
|
Use the following code:
int nKeyCount = pIniFileObj->getSectionData(strSectionName)->GetCount();
|
|
|
|
|
Hi,
Thanks for this great article.It Helped me a lot!!
Yog
|
|
|
|
|
|
This class is based on C++.
But your code is C# 
|
|
|
|
|
How nice
Thanks 
|
|
|
|
|
I want to know whether if you can give the relative path to the ini file instead of the absolute path
|
|
|
|
|
Use ./ for current directory
|
|
|
|
|
realyy good work, thanks much.
caner abalı
|
|
|
|
|
A very good work by my senior
Adnan Shaheen
Quaid-i-Azam University
|
|
|
|
|
Quit honestly, there are many issues related that you have overlooked while commenting, I must say that, some are as follows.
1) No overloaded copy constructors & assignment operator
2) returning of non-constant pointer of class privates
3) passing parameters by value, rather then constant reference
4) Usage of CString, rather then std::string
5) Weak interface
Regards,
Ejaz.
-- modified at 8:07 Saturday 15th October, 2005
|
|
|
|
|
|
Portability is my major concern, thats why I dumped the idea of using .ini files quite sometime back and use boost::serialization
Regards
|
|
|
|
|
Hye!!
I would like to know how I can remove a key?
Thanks.
|
|
|
|
|
long CIniReader::delKey(CString strValue, CString strKey, CString strSection)
{
m_lRetValue = WritePrivateProfileString (strSection, strKey,
NULL, m_strFileName);
return m_lRetValue;
}
|
|
|
|
|
Good, This helped me a lot.
Regards,
Rajendran
|
|
|
|
|
Hi,
when i'm using CIniReader Class outside the TestIni Project,
with VC++6.0 i get the following error:
(sorry, i'm just a beginner)
Linking...
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Debug/Test.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
Can anyone help me? Thanx.
|
|
|
|
|
This is probably because of your inappropriate project settings:
Following is what i am pasting from MSDN.
------------------------------------------------------------
When compiling an MFC application using the single-threaded run-time library, you receive the following two unresolved external error messages:
nafxcwd.lib(thrdcore.obj) : error LNK2001:
unresolved external symbol "__beginthreadex"
nafxcwd.lib(thrdcore.obj) : error LNK2001:
unresolved external symbol "__endthreadex"
--------------------------------
Solution:
Select the PROJECT menu
Select the SETTINGS... option.
Select the tab, C/C++.
Select CODE GENERATION on the Category list box.
Finally, make a selection other than SINGLE-THREADED on the Use Run Time Library list box.
--------------------------
for details refer to MSDN.
@!$h@
|
|
|
|
|
Just to tell you, this class is not based on MFC, instead it uses SDK functions. So you can use my class anywhere, in your C++, Win32 or MFC code. Enjoy!!;)
@!$h@
My free code and articles website http://aishai.netfirms.com
|
|
|
|
|
looking at the header file, I found #include <afxcoll.h> and functions returning CString. I doubt I can really use it in any non-MFC project. 
|
|
|
|
|
I had a ini file that had around 20 sections, each of which had around 5000 key pair values. Used this class, seems like it was taking forever to read/write through these set of classes.
Could you please improve its performance, or atleast advise me how can i do this?
Thanks a lot
|
|
|
|
|