I create a MFC (exe) in VC++ 6 with
name ThreadExample. In CThreadExampleDlg,
I have two function below :
DWORD WINAPI CThreadExampleDlg::ThreadFunc( LPVOID lpParam )
{
MessageBox("Thread created.", MB_OK );
return 0;
}
void CThreadExampleDlg::RunEx()
{
DWORD dwThreadId, dwThrdParam = 1;
HANDLE hThread;
hThread = CreateThread(
NULL, // no security attributes
0, // use default stack size
ThreadFunc, // thread function
&dwThrdParam, // argument to thread function
0, // use default creation flags
&dwThreadId); // returns the thread identifier
// Check the return value for success.
if (hThread == NULL)
MessageBox( "CreateThread failed." );
CloseHandle( hThread );
}
It generate an error below :
Cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned long (__stdcall *)(void *)'. None of functions with this name in scope match the target.
I had use some way consist cast type ThreadFunc to
LPTHREAD_START_ROUTINE) ThreadFunc but it continue generate error.
How can I fix this problem ?