ホーム » MFC » AppName.ini

2024年1月
 123456
78910111213
14151617181920
21222324252627
28293031  

カテゴリー

アーカイブ

ブログ統計情報

  • 115,195 アクセス


AppName.ini

何年か前に作成したツールをビルドしていて,ちょっと気になったこと.
exe 名を変更した時,設定値がうまく引き継がれない.
レジストリを使用している時は AFX_IDS_APP_TITLE を追加すれば良いが ini では効果がない.
CWinApp::SetCurrentHandles()    m_pszProfileName


最近書いたコードからは,次の様に m_pszProfileName を変更する様にしている.

BOOL	RI_Set_ProfileName		(void)
{
	CWinApp*	app = AfxGetApp() ;
	if (app == NULL)    	{	return	FALSE ;		}
	CString		nowINI = app->m_pszProfileName ;
	CString		newINI = ::INI_get_module_ini().c_str() ;
	if (nowINI == newINI)	{	return	TRUE ;		}
	free((void*)app->m_pszProfileName) ;
	app->m_pszProfileName = _tcsdup(newINI) ;
	{
		std::tout << _T("org=") << LPCTSTR(nowINI) << std::endl ;
		std::tout << _T("new=") << LPCTSTR(newINI) << std::endl ;
		}
	return	TRUE ;
	}
BOOL	RI_Set_RegistryKey		(void)
{
	CWinApp*	app = AfxGetApp() ;
	if (app == NULL)	{	return	FALSE ;		}
	CString		nowKey = app->m_pszRegistryKey ;
	CString		newKey = ::REG_get_product().c_str() ;
	if (nowKey == newKey)	{	return	TRUE ;		}
	{
		free((void*)app->m_pszRegistryKey) ;
		app->m_pszRegistryKey = _tcsdup(newKey) ;
		}
	CString		nowApp = app->m_pszProfileName ;
	CString		newApp = app->m_pszAppName ;
	if (nowApp == newApp)	{	return	TRUE ;		}
	{
		free((void*)app->m_pszProfileName) ;
		app->m_pszProfileName = _tcsdup(app->m_pszAppName) ;
		}
	{
		std::tout << _T("org=") << LPCTSTR(nowKey) << std::endl ;
		std::tout << _T("new=") << LPCTSTR(newKey) << std::endl ;
		}
	return	TRUE ;
	}
Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

1件のコメント

コメントは停止中です。

%d人のブロガーが「いいね」をつけました。