How to delete a section from an INI file

4 01 2010

 

 

If you have ever needed to remove a section completely from an INI file.

 

 

We can use WritePrivateProfileStruct API to achieve this. We have to set NULL as the 2nd parameter to delete a section completely and set NULL as the 3rd parameter to delete a particular key only.

 

 

void DeleteSectionFromIniFile() 
{
   WritePrivateProfileStruct(_T("Section 1"), NULL, NULL, 0, _T("C:\\test.ini"));
}

 

 

WritePrivateProfileString too use for the same purpose.

Advertisements

Actions

Information

2 responses

1 08 2013
David

This is perfect. Thank you!

1 08 2013
Sanoop S P

Thank you.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: