Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to use Create a CWinThread in MFC Extension DLL?

47 views
Skip to first unread message

delu

unread,
Aug 8, 2003, 10:48:14 AM8/8/03
to
Hi guys,

I want to use AfxBeginThread or CreateThread to create a
thread which can monitor com port in MFC Extension DLL
like following:

class AFX_EXT_CLASS CInitDll
{..};


BOOL CInitDll::StartMonitoring()
{
DWORD Tid;
if (!(m_Thread = CreateThread (
NULL,
0,
(LPTHREAD_START_ROUTINE) CommThread,
this,
0,
&Tid)
))
return FALSE;
TRACE("Thread started\n");
return TRUE;
}

DWORD WINAPI CommThread(LPVOID cOwner)
{....}

but I meet:
error C2440: '=' : cannot convert from 'void *' to 'class
CWinThread *'

How to use Create a CWinThread in MFC Extension DLL?


Scott McPhillips

unread,
Aug 8, 2003, 7:16:28 PM8/8/03
to

CreateThread is an API function that does not return a CWinThread*.
AfxBeginThread is an MFC function and does return a CWinThread* and
should always be used instead of CreateThread in MFC code.

--
Scott McPhillips [VC++ MVP]

0 new messages