Total Visual SourceBook

Total Visual SourceBook CD and Printed Manual

Microsoft Access/ Office 2016, 2013, 2010, and 2007 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office 2007 and VB6

Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!

Separate version for Access/Office 2003, 2002, and 2000.

Separate version for:
Access 97/95


View all FMS products for Microsoft AccessAll Our Microsoft Access Products

SourceBook Info:

Why SourceBook?

 

"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP

 

 

 

Microsoft Access, Office/VBA, VB6 Modules royalty-free source code libraryMicrosoft Access Modules royalty-free source code libraryMicrosoft Access VBA and VB6 Module Library Free trial of Total Visual SourceBook for Microsoft Access, Office, VB6 and VBA

Module: INIFile in Category Windows : INI File from Total Visual SourceBook

Windows Initialization (INI) files code in VB6 and VBA with 32 and 64 bit Windows API calls.

Initialization (INI) files are the primary mechanism that 16-bit Windows programs use to store setting information. Additionally, Windows itself stores its settings for the most part in various INI files in the Windows directory. Even in the 32-bit world, INI files are still used. This category contains procedures to read and write INI file values in both the built-in Windows files and your own custom INI files. Windows splits INI file access into two categories: 1. INI Operations: all operations are hardcoded to go to the WIN.INI file located in the Windows directory. 2. Private INI: all operations work on the INI file specified in the call. Use the "private" INI functions to work with all INI files other than WIN.INI. Interestingly, you can use the "private" INI functions on WIN.INI by specifying WIN.INI as the file to work with.

Procedure List

Procedure Name

Type

Description

(Declarations) Declarations Declarations and private variables for the modINIFile module
INIGetSettingInteger Procedure Get an integer value from the specified INI file
INIGetSettingString Procedure Get a string value from the specified INI file
INIWriteSetting Procedure Writes the specified value to the specified INI file
WinINIGetSettingInteger Procedure Get an integer value from WIN.INI
WinINIGetSettingString Procedure Get a string value from the WIN.INI file
WinINIWriteSetting Procedure Writes the specified value to WIN.INI

Example Code for Using Module: INIFile

' Example of the modINIFile module
'
' To use this example:
' 1. Create a new form.
' 2. Create a command button called cmdTest
' 3. Paste the entire contents of this module into the new form's module.
'
' This example assumes that the sample files are located in the folder named by the following constant.
Private Const mcstrSamplePath As String = "C:\Total Visual SourceBook 2013\Samples\"

Private Sub cmdTest_Click()
  ' This procedure shows how to use the modINIFile module.

  Const cstrPrivateINI As String = mcstrSamplePath & "FMSTEST.INI"

  Dim intRet As Integer
  Dim fOK As Boolean
  Dim strRet As String

  ' First, lets get some information from the WIN.INI file
  intRet = WinINIGetSettingInteger("Desktop", "WallpaperStyle")
  Debug.Print "Your Wallpaper style as defined in Win.INI is: " & intRet

  ' Next, get a string
  strRet = WinINIGetSettingString("INTL", "sLongDate")
  Debug.Print "Your Long Date format is: " & strRet

  ' Let's change the wallpaper (this line is commented out so we don't actually make changes to your system.
  ' Note also that the following code only changes wallpaper settings under Windows 3.x.
  ' fOK = WinINIWriteSetting("Desktop", "Wallpaper", "tiles.bmp")
  If fOK Then
    Debug.Print "Changed your wallpaper to tiles.bmp"
  Else
    Debug.Print "Couldn't change your wallpaper."
  End If

  ' Now we'll work with a "private" ini file (any ini file other the WIN.INI).
  strRet = INIGetSettingString("Favorites", "Color", cstrPrivateINI)
  Debug.Print "Your favorite color is: " & strRet

  ' Get an integer value
  intRet = INIGetSettingInteger("Secret", "PIN", cstrPrivateINI)
  Debug.Print "Your bank PIN number is: " & intRet

  ' Change our favorite color to Blue
  fOK = INIWriteSetting("Favorites", "Color", "Blue", cstrPrivateINI)
  If fOK Then
    Debug.Print "Your favorite color is now Blue."
  Else
    Debug.Print "Couldn't change INI file."
  End If

End Sub

Microsoft Access Module LibraryOverview of Total Visual SourceBook

The source code in Total Visual SourceBook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Additional Resources