ホーム » MFC » AfxGetInstanceHandle

2023年9月
 12
3456789
10111213141516
17181920212223
24252627282930

カテゴリー

アーカイブ

ブログ統計情報

  • 80,753 アクセス



AfxGetInstanceHandle

コンソール AP を変更していて「MFC を使用」にすると AfxGetInstanceHandle で ASSERT .
AfxGetInstanceHandle ASSERT

---------------------------
Microsoft Visual C++ Debug Library
---------------------------
Debug Assertion Failed!

Program: c:\Temp\TOutline\tolmba\Debug.060\tolmba.exe
File: afxwin1.inl
Line: 19

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.

(Press Retry to debug the application)
---------------------------
中止(A)   再試行(R)   無視(I)   
---------------------------

この単体テスト用プロジェクトは,最初 MFC を使用しないでコードを書いていた.
が,幾つかの機能を付けていくと MFC を使用した既存のコードが必要になった.
その中で AfxGetInstanceHandle() を呼出している所があり,そこで ASSERT .


次の様に MFC の初期化 ::AfxWinInit を追加して対応.

int	_tmain	(int argc,TCHAR* argv[])
{
	#ifdef	_MFC_VER
	if (!::AfxWinInit(::GetModuleHandle(NULL),NULL,::GetCommandLine(),0)) {
		return	1 ;
		}
	#endif
	_tsetlocale(LC_ALL,_T("")) ;
//	...
	return	0 ;
	}
Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.
%d人のブロガーが「いいね」をつけました。