次の方法で共有


CWinApp::m_pszRegistryKey

レジストリ、または INI ファイルで、アプリケーションのプロファイル設定が格納される場所を決定するために使用します。

LPCTSTR m_pszRegistryKey;

解説

通常、このデータ メンバーは読み取り専用として扱われます。

  • 値はレジストリ キーに格納されます。 アプリケーションのプロファイル設定の名前は、次のレジストリ キーに追加されます: HKEY_CURRENT_USER/Software/LocalAppWizard-Generated/.

m_pszRegistryKeyに値を割り当てる場合は、ヒープに動的に割り当てる必要があります。 CWinApp のデストラクターはこのポインターの free( ) を呼び出します。 複数割り当てることに _tcsdup( ) ランタイム ライブラリ関数を使用します。 また、新しい値を割り当てる前に現在のポインターに関連付けられているメモリを解放します。 以下はその例です。

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

必要条件

ヘッダー: afxwin.h

参照

関連項目

CWinApp クラス

階層図

CWinApp::SetRegistryKey