16,015,756 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Bruce Munck (Top 4 by date)
Bruce Munck
31-Dec-17 10:31am
View
Well, here goes. The leading quotes are supposed to contain the name of the section enclosed in "[]". For some reason that is being deleted. If this doesn't work I guess I'll give up.
Bruce Munck
31-Dec-17 10:27am
View
Ok, I guess my entries are being changed. Let's try this: n = WritePrivateProfileString(, <key>, <value>, <inipath>). should appear in all the calls.
Bruce Munck
31-Dec-17 10:22am
View
In my comment and solution I left closed quotes where there should have been the following: "". Sorry.
Bruce Munck
31-Dec-17 10:16am
View
If you are looking for the easiest way to delete items fron an INI file, try using the API like this: n = WritePrivateProfileString("", "<key>", 0&, "<inipath>"). This will delete a single key and its value.
To delete an entire section, use this: n = WritePrivateProfileString("", 0&, "<value>", "<inipath>"). The following will do the same thing n = WritePrivateProfileString("", 0&, 0&, "<inipath>"). Use of either construct is correct, so choose the one you like best.
To add to an INI file: n = WritePrivateProfileString("", "<key>", "<value>", "<inipath>").
As for the WriteIni function in this article, I am not the author. I also ran into it while searching for ini file solutions several years ago and have been using it as written without any problems since around 2008. The only thing this code does that using the API "WritePrivateProfileString" does not do is to put a blank line between sections. So, on the one hand, if you don't need or care about blank lines making the file more readable, you really don't need to use this code since the API will do all the other formatting for you with a one-line call. On the other hand, if you like the idea of blank lines between sections, then this piece of code is an easy way of having them inserted properly. I have no idea why the author chose to make it a function, but it isn't a big chore to change it to a SUB. As for the GOTO's, I recently re-wrote this routine as a SUB and wrote all of the GOTO targets as separate SUB's and changed the GOTO's to standard calls. I think the original, with the GOTO's, looks neater than the re-written code. I am also of the opinion that the GOTO's were done properly and don't hurt anything. Having said that, I now use, and will continue to use, my re-written version of the above code, sans GOTO's, as it is more acceptable.