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