|
-
June 7th, 1999, 02:28 PM
#1
"abnormal program termination"?!
Hi there,
I'm trying to write a class that reads and writes INI files. One of my class's member function is
CINIKey::EnumSection(string& szBuffer, const int index) which just returns a string containing the
section name of a specific index in an INI file. The code I have is the following.
bool CINIKey::EnumSection(string& szBuffer,const int index)
{
for(int i=0;i<=index;i++)
{
szBuffer=ExtractSection();
nStartPos+=szBuffer.length();//Advance the position so it reads the next available section
}
if(szBuffer.size()==0) //No more section is left to extract
return false;
else
return true; //Still more sections left to be extracted
}
The call to ExtractSection() just extracts and returns a the string containing the section name specified by
nStartPos which is initially 0 so it searches for the first [section name] in the file. If I increase nStartPos
to after the first section's end bracket, then it will find the next section by finding another '['. Anyway,
I try to use the EnumSection like the following...
CINIKey key;
bool bResult;
int i;
for(i=0,bResult=true;bResult==true;i++)
{
bResult=key.EnumSection(value,i);
cout << value << endl;
}
That code is supposed to list all the section name in the INI file one by one and it actually works. The
problem is I also get the error message "abnormal program termination" at the end. It's also apprent that
the program terminates BEFORE my main returns anything! Please tell me what's wrong. Thanks.
-
June 7th, 1999, 03:11 PM
#2
Re: "abnormal program termination"?!
Why would you want to write a class to read/write to ini files when you can use GetProfileString/WriteProfileString !?!?!?!?
Only a comment...
Have a nice day 
-
June 7th, 1999, 07:55 PM
#3
Re: "abnormal program termination"?!
Hi there,
I know API supports it but it's not enought for me. For example, I'd like to enumerate the sections or
entries.
-
June 7th, 1999, 08:06 PM
#4
Re: "abnormal program termination"?!
You can enumerate sections and keys with it too 
-
June 8th, 1999, 11:55 AM
#5
Re: "abnormal program termination"?!
Hi there,
Can they? From the doc in MSDN, both Write/ReadProfileString() require the section and entry
name for the parameters. What if we DO NOT know the names?
-
June 8th, 1999, 01:24 PM
#6
Re: "abnormal program termination"?!
please take a look at functions like :
GetPrivateProfileSectionNames
http://msdn.microsoft.com/library/sd...egapi_3k1f.htm
you should be using the registry anyway...
adiós!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|