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.
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.