CWinApp::GetProfileString
CStringGetProfileString(LPCTSTRlpszSection**,LPCTSTRlpszEntry,LPCTSTRlpszDefault=NULL);**
Return Value
The return value is the string from the application’s .INI file or lpszDefault if the string cannot be found. The maximum string length supported by the framework is _MAX_PATH. If lpszDefault is NULL, the return value is an empty string.
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 string is to be retrieved. This value must not be NULL.
lpszDefault
Points to the default string value for the given entry if the entry cannot be found in the initialization file.
Remarks
Call this member function to retrieve the string associated with an entry within the specified section in 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.
Example
CString strSection = "My Section";
CString strStringItem = "My String Item";
CString strIntItem = "My Int Item";
CWinApp* pApp = AfxGetApp();
pApp->WriteProfileString(strSection, strStringItem, "test");
CString strValue;
strValue = pApp->GetProfileString(strSection, strStringItem);
ASSERT(strValue == "test");
pApp->WriteProfileInt(strSection, strIntItem, 1234);
int nValue;
nValue = pApp->GetProfileInt(strSection, strIntItem, 0);
ASSERT(nValue == 1234);
CWinApp Overview | Class Members | Hierarchy Chart
See Also CWinApp::GetProfileInt, CWinApp::WriteProfileString,