GetProfileInt Function

Declare Function GetProfileInt Lib "kernel32.dll" Alias "GetProfileIntA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal nDefault As Long) As Long

Platforms: Win 32s, Win 95/98, Win NT

GetPrivateProfileInt reads an integer value from the WIN.INI file. The parameters passed to the function specify which value will be read from. If successful, the function returns the value read. If the value you specify does not exist or is a string (i.e., not a number), the value specified as nDefault is returned. This is basically a watered-down version of GetPrivateProfileInt because, unlike it, this function only works with WIN.INI. Note that INI file support is only provided in Windows for backwards compatibility; using the registry to store information is preferred.

lpAppName
The header of the WIN.INI file section the value is in.
lpKeyName
The name of the value to read.
nDefault
The value to return if a valid value cannot be read. Make it something that would definitely not be read, such as -1.

Example:

' Read the value "WallpaperStyle" under the [Desktop]
' section of the WIN.INI file.  Return -1 if an error occured.
Dim wstyle As Long  ' receives the information read from WIN.INI

' Read the data from WIN.INI
wstyle = GetProfileInt("Desktop", "WallpaperStyle", -1)
If wstyle = -1 Then
  Debug.Print "Could not read the data from WIN.INI."
Else
  Debug.Print "Wallpaper Style:"; wstyle
End If

Related Call: GetPrivateProfileInt, GetProfileString
Category: INI Files
Back to the index.


Go to Paul Kuliniewicz's Home Page.
E-mail: rogue953@hotmail.com
This page is at http://skyscraper.fortunecity.com/transmission/45/api/g/getprofileint.html