Windows API Guide - Reference - Volume 1: Version 3.0 For the MS-DOS and PC-DOS Operating Systems
Declare Function GetProfileInt Lib "kernel32.dll" Alias "GetProfileIntA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal nDefault As Long) As Long
Platforms
- Windows 95: Supported.
- Windows 98: Supported.
- Windows NT: Requires Windows NT 3.1 or later.
- Windows 2000: Supported.
- Windows CE: Requires Windows CE 1.0 or later.
Description & Usage
GetProfileInt reads an integer value from the WIN.INI file. The parameters passed to the function specify which value will be read from. This is basically a watered-down version of GetPrivateProfileInt because, unlike it, this function only works with WIN.INI.
Return Value
If successful, the function returns the integer value read from the INI file. If the specified key could not be found, the function returns the value passed as nDefault.
Visual Basic-Specific Issues
None.
Parameters
- 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. This should typically be a default setting for the value, or something that would indicate that the value could not be read.
Example
Read the value "WallpaperStyle" from the [Desktop] section of the WIN.INI file and display it. To use this example, place a command button named Command1 on a form window.
' This code is licensed according to the terms and conditions listed here. ' Declarations and such needed for the example: ' (Copy them to the (declarations) section of a module.) Public Declare Function GetProfileInt Lib "kernel32.dll" Alias "GetProfileIntA" (ByVal lpAppName _ As String, ByVal lpKeyName As String, ByVal nDefault As Long) As Long ' *** Place the following code inside the form window. *** Private Sub Command1_Click() Dim value As Long ' value read from WIN.INI ' Read the desired value. value = GetProfileInt("Desktop", "WallpaperStyle", -1) ' Display the result. If value = -1 Then Debug.Print "Could not read the value!" Else Debug.Print "WallpaperStyle ="; value End If End Sub
See Also
GetPrivateProfileInt, GetProfileString
Category
INI Files
Go back to the Function listing. Go back to the Reference section index.
Last Modified: January 21, 2001 This page is copyright © 2001 Paul Kuliniewicz. Copyright Information Revised October 29, 2000 Go back to the Windows API Guide home page. E-mail: vbapi@vbapi.com Send Encrypted E-Mail This page is at http://www.vbapi.com/ref/g/getprofileint.html