AR INI Manager ActiveX Library 1.01

This library will allow you to manage INI files in a very simple way. Just with a few methods you will be able to read, write and list the whole contents of INI files.

History:

  • 26.03.98: Version 1.0 released.
  • 12.04.98, version 1.01: a couple of internal small things changed.

Properties:

  • FileName. Set here the full path of the INI file that you want to access.
  • Section (SectionName As String) As Collection. Call this property to get a collection with all the keys inside a section. This collection will contain objects with two properties: Key and Value.
  • Sections As Collection. Use this property to get a collection containing all the section names in an INI file. This collection will have just the names of the section.

Methods:

  • DeleteKey (Section As String, Key As String) As Boolean. This method will erase the specified key from the specified section. True if succesful, and False if it fails.
  • DeleteSection (Section As String) As Boolean. This method will delete a section and all its contents. True if succesful, and False if it fails.
  • GetString (Section As String, Key As String, [Default As String]) As String. This property will return the value of the specified key in the specified section. If it doesn't exist, it will return the value set in Default (default is an empty string).
  • WriteString (Section As String, Key As String, Value As String) As Boolean. This method will set Value to Key in the specified Section. If Key or Section doesn't exist, it will create them. If Key exists, the function will replace its value.

Examples:

To start using the library:

Dim INIMan As New ARINIMan
INIMan.FileName = "c:\test.ini"

To write information to the INI file:

Dim Res as Boolean
Res = INIMan.WriteString("Paths", "App Path", "MyApplicationPath")
Res = INIMan.WriteString("Paths", "Data Path", "MyDataPath")
Res = INIMan.WriteString("Appearance", "3D", "True")
Res = INIMan.WriteString("Appearance", "Top", "TopValue")
Res = INIMan.WriteString("Appearance", "Left", "LeftValue")

To get the number of sections in the INI file and the name of the first section:

NumberOfSections=INIMan.Sections.Count
NameOfFirst=INIMan.Sections(1)

To get the number of keys in a section:

NumberOfKeys=INIMan.Section("Paths").Count
or NumberOfKeys=INIMan.Section(INIMan.Sections(1)).Count

To get the value of the Top key in the Appearance section:

Value = INIMan.Section("Appearance")("Top").Value (this one only works if the key really exists)
or Value = INIMan.GetString("Appearance", "Top", "MyDefault")

The methods to delete don't require any explanation. If you have questions or bugs, please contact me.

 

(10 Kb)

© Alvaro Redondo, 1998. All Rights Reserved.
http://www.sevillaonline.com/ActiveX/