UINT GetProfileInt(lpszSection, lpszEntry, default) | |||||
LPCSTR lpszSection; | /* address of section | */ | |||
LPCSTR lpszEntry; | /* address of entry | */ | |||
int default; | /* return value if entry is not found | */ |
The GetProfileInt function retrieves the value of an integer from an entry within a specified section of the WIN.INI initialization file.
lpszSection
Points to a null-terminated string that specifies the section containing the entry.
lpszEntry
Points to the null-terminated string containing the entry whose value is to be retrieved.
default
Specifies the default value to return if the entry cannot be found. This value can be an unsigned value in the range 0 through 65,536 or a signed value in the range –32,768 through 32,768. Hexadecimal notation is accepted for both positive and negative values.
The return value is the integer value of the string following the specified entry, if the function is successful. The return value is the value of the default parameter if the function does not find the entry. The return value is zero if the value that corresponds to the specified entry is not an integer.
The GetProfileInt function is not case-dependent, so the strings in the lpszSection and lpszEntry parameters may contain a combination of uppercase and lowercase letters.
GetProfileInt supports hexadecimal notation. When the function is used to retrieve a negative integer, the value should be cast to an int.
An integer entry in the WIN.INI file must have the following form:
[section]
entry=value
.
.
.
If the value that corresponds to the entry consists of digits followed by nonnumeric characters, the function returns the value of the digits. For example, the function would return 102 for the line “Entry=102abc”.
An application can use the GetPrivateProfileInt function to retrieve an integer from a specified file.
The following example uses the GetProfileInt function to retrieve the screen-save timeout time from the WIN.INI file:
WORD wTimeOut;
char szMsg[80];
wTimeOut = GetProfileInt("windows",
"ScreenSaveTimeOut", 0);
sprintf(szMsg, "timeout time is %d", wTimeOut);
MessageBox(hwnd, szMsg, "GetProfileInt", MB_OK);