共用方式為


CWinApp::m_pszRegistryKey

LPCTSTRm_pszRegistryKey;

Remarks

Used to determine where, in the registry or INI file, application profile settings are stored. Normally, this data member is treated as read-only.

Registry entries are stored as follows:

  • In Windows NT, the value is stored to a registry key. The name for the application profile setting is appended to the following registry key: HKEY_CURRENT_USER/Software/LocalAppWizard-Generated/.

  • 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.

If you assign a value to m_pszRegistryKey, it must be dynamically allocated on the heap. The CWinApp destructor calls free( ) with this pointer. You many want to use the _tcsdup( ) run-time library function to do the allocating. Also, free the memory associated with the current pointer before assigning a new value. For example:

//First free the string allocated by MFC at CWinApp startup.
//The string is allocated before InitInstance is called.
free((void*)m_pszRegistryKey);
//Change the name of the registry key.
//The CWinApp destructor will free the memory.
m_pszRegistryKey=_tcsdup(_T(“HKEY_CURRENT_USER\\Software\\mycompany\\myapp\\thissection\\thisvalue”));

CWinApp OverviewClass MembersHierarchy Chart

See Also   CWinApp::SetRegistryKey