CWinApp::WriteProfileInt

BOOLWriteProfileInt(LPCTSTRlpszSection**,LPCTSTRlpszEntry,intnValue);**

Return Value

Nonzero if successful; otherwise 0.

Parameters

lpszSection

Points to a null-terminated string that specifies the section containing the entry. If the section does not exist, it is created. The name of the section is case independent; the string may be any combination of uppercase and lowercase letters.

lpszEntry

Points to a null-terminated string that contains the entry into which the value is to be written. If the entry does not exist in the specified section, it is created.

nValue

Contains the value to be written.

Remarks

Call this member function to write the specified value into the 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.

Example

This example uses CWinApp* pApp = AfxGetApp(); to get at the CWinApp class illustrating a way that WriteProfileString, WriteProfileInt, GetProfileString, and GetProfileInt can be used from any function in an MFC application.

   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);

For another example, see the example for CWinApp::GetProfileInt.

CWinApp OverviewClass MembersHierarchy Chart

See Also   CWinApp::GetProfileInt, CWinApp::WriteProfileString, CWinApp::SetRegistryKey