GetPrivateProfileInt Function

Declare Function GetPrivateProfileInt Lib "kernel32.dll" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Long, ByVal lpFileName As String) As Long

GetPrivateProfileInt reads an integer value from any 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.

lpApplicationName
The header of the 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.
lpFileName
The filename of the INI file to read from.

Example:

' Read the value "type" under the [keyboard] section of SYSTEM.INI
' These next few lines get the Windows directory....
Dim buffer As String * 255
x = GetWindowsDirectory(buffer, 255)
sysini = Left(buffer, x) & "\system.ini"
' Now read the value
ret = GetPrivateProfileInt("keyboard", "type", -1, sysini)
If ret = -1 Then
  Debug.Print "Could not read data."
Else
  Debug.Print ret
End If

Related Calls: GetPrivateProfileString, GetProfileInt
Category: INI Files
Back to the index.


Back to Paul Kuliniewicz's Home Page
E-mail: Borg953@aol.com
This page is at http://members.aol.com/Borg953/api/functions/getprivateprofileint.html