Fog Creek Software
g
Discussion Board




Delete a section from within an INI file

What was that API if you wanted to delete a section from within an INI file? My memory completely fails me. I've looked around with Dependency Walker in kernel32 for DeleteSection or DeleteValue or something but I dont get any entry of that kind.

Or was it that you had to play around with WritePrivateProfileString to delete the section too, giving it a nullstring value?

Sathyaish Chakravarthy
Thursday, October 23, 2003

Uh...

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&q=delete+section+from+INI+file&sa=N&tab=wg

IOTTOO
Friday, October 24, 2003

Thanks!

And I am sorry for putting it up here. I can see you are not that happy.

Sathyaish Chakravarthy
Friday, October 24, 2003

The MSDN Library has all the information on WriteProfileString you could ever want.

Daren Thomas
Friday, October 24, 2003

>I can see you are not that happy. <

Not at all. But checking groups.google.com should always be one of the first things you do when you have a technical question. Another good site is

http://www.tek-tips.com

(You have to register in order to be able to post messages, but it is free and even if you don't register, you can still read and search messages)

IOTTOO
Friday, October 24, 2003

May I put in a plug to avoid the windows built-in INI file reading and writing code like the plague?

Flamebait Sr.
Friday, October 24, 2003

Flamebait Sr., I do remember having read so and going in for the File I/O instead to read the INI and write to it but I have quite forgotten why.

I'd been to tek-tips but one day I couldn't sign in. They'd probably been doing some house-keeping with their database. I didn't follow up then and didn't try logging in ever again.

Sathyaish Chakravarthy
Monday, October 27, 2003

Well, to put it bluntly, because the INI file code sucks and is an antiquated leftover from at least Windows 3.0, perhaps even earlier.

As file size increases (64k+), it starts to develop quirky behaviour.

The interface is clunky with how it forces you to guess as to the correct size of a key, which can get ugly real fast.

Things like that.  It was intended to work kinda sorta like the registry does today, back before there was a registry.  Either use the registry to store config values or roll your own file parsing code.

Flamebait Sr.
Monday, October 27, 2003

Then I got you wrong. So what you're saying is that there's not so much ugliness in the API interface than there is in the INI files itself? I am using a combination of INI, Registry, XML files and my own file parsing too for persistence. I've been using the Registry for long but only days ago I realized that some users on the network did not have rights to edit thier Registry. In fact while the application ran successfully in three offices, in one of the offices it ran on neither of the machines because none of the users had adequate rights. Since we are in a free market economy where the consumer is the king, I am now considering a change of option for the entire application (and its ancillary components, five of them) that eliminates the interface to the Registry altogether instead of asking the client to request a change in the network user rights for that office. Quite painful.

Sathyaish Chakravarthy
Tuesday, October 28, 2003

*  Recent Topics

*  Fog Creek Home