CWinApp::GetProfileInt
UINTGetProfileInt(LPCTSTRlpszSection**,LPCTSTRlpszEntry,intnDefault);**
Return Value
The integer value of the string that follows the specified entry if the function is successful. The return value is the value of the nDefault parameter if the function does not find the entry. The return value is 0 if the value that corresponds to the specified entry is not an integer.
This member function supports hexadecimal notation for the value in the .INI file. When you retrieve a signed integer, you should cast the value into an int.
Parameters
lpszSection
Points to a null-terminated string that specifies the section containing the entry.
lpszEntry
Points to a null-terminated string that contains the entry whose value is to be retrieved.
nDefault
Specifies the default value to return if the framework cannot find the entry. This value can be an unsigned value in the range 0 through 65,535 or a signed value in the range –32,768 through 32,767.
Remarks
Call this member function to retrieve the value of an integer from an entry within a specified section of the application’s registry or .INI file.
The entries are stored as follows:
In Windows NT, the value is stored to a registry key.
In Windows 3.x, the value is stored in the WIN.INI file.
In Windows 95, the value is stored in a cached version of WIN.INI.
This member function is not case sensitive, so the strings in the lpszSection and lpszEntry parameters may differ in case.
Example
BOOL CMyApp::InitInstance()
{
// CMyApp is derived from CWinApp.
const char *pszKey = "MyApp";
const char *pszName = "Julian";
int iAge = 26;
// Change the registry key under which our settings are stored.
SetRegistryKey(_T(""));
// Write the information to the registry.
WriteProfileString(pszKey, "Name", pszName);
WriteProfileInt(pszKey, "Age", iAge);
// Read the information from the registry.
CString strName = GetProfileString(pszKey, "Name");
int iAge2 = GetProfileInt(pszKey, "Age", 0);
ASSERT(strName == pszName);
ASSERT(iAge2 == iAge);
return TRUE;
}
For an additional example, see CWinApp::WriteProfileInt.
CWinApp Overview | Class Members | Hierarchy Chart
See Also CWinApp::GetProfileString, CWinApp::WriteProfileInt,