Configuration File Module using PrivateProfile WinAPI functions
Category:
C#, VB.NET, ASP.NETType:
ModulesDifficulty:
IntermediateAuthor:
AnonymousVersion Compatibility: Visual Basic.NET
More information:
This is basically just a wrapper module for the PrivateProfile set of functions in kernel32. It fills in several of the blanks I've found with these functions over the years, such as:
Minimum and maximum values for numeric reads
Automatically increasing buffers for string reads
Returning arrays instead of null-terminated strings
Functions for deleting or clearing of keys, sections, or the whole config file
Correct writing of boolean values as 1 or 0
Saving to/restoring from a backup
Using this module to save your program's settings is far easier and less cumbersome than using the registry. For instance, you can save and load the value of a checkbox in one line each:
Config.WriteKey("Settings", "SomeCheckbox", SomeCheckbox.Checked)
SomeCheckbox.Checked = Config.ReadIntKey("Settings", "SomeCheckbox")
Instructions: Click the link below to download the code. Select 'Save' from the IE popup dialog. Once downloaded, open the .zip file from your local drive using WinZip or a comparable program to view the contents.
Download config_file_module.zip