AfxBeginThread CWinThread* AfxBeginThread( AFX_THREADPROC pfnThreadProc, LPVOID pParam, int nPriority = THREAD_PRIORITY_NORMAL, UINT nStackSize = 0, DWORD dwCreateFlags = 0, LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL );CWinThread* AfxBeginThread( CRuntimeClass* pThreadClass, int nPriority = THREAD_PRIORITY_NORMAL, UINT nStackSize = 0, DWORD dwCreateFlags = 0, LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL );Return ValuePointer to the newly created thread object.ParameterspfnThreadProcPoints to the controlling function for the worker thread. Cannot be NULL. This function must be declared as follows:UINT MyControllingFunction( LPVOID pParam );pThreadClassThe RUNTIME_CLASS of an object derived from CWinThread.pParamParameter to be passed to the controlling function as shown in the parameter to the function declaration in pfnThreadProc.nPriorityThe desired priority of the thread. If 0, the same priority as the creating thread will be used. For a full list and description of the available priorities, seeSetThreadPriority in the Win32 Programmer’s Reference.nStackSizeSpecifies the size in bytes of the stack for the new thread. If 0, the stack size defaults to the same size stack as the creating thread.dwCreateFlagsSpecifies an additional flag that controls the creation of the thread. This flag can contain one of two values: CREATE_SUSPENDED Start the thread with a suspend count of one. The thread will not execute until ResumeThread is called. 0 Start the thread immediately after creation. lpSecurityAttrsPoints to a SECURITY_ATTRIBUTES structure that specifies the security attributes for the thread. If NULL, the same security attributes as the creating thread will be used. For more information on this structure, see the Win32 Programmer’s Reference.ResCall this function to create a new thread. The first form of AfxBeginThread creates a worker thread. The second form creates a user-interface thread. AfxBeginThread creates a new CWinThread object, calls its CreateThread function to start executing the thread, and returns a pointer to the thread. Checks are made throughout the procedure to make sure all objects are deallocated properly should any part of the creation fail. To end the thread, call AfxEndThread from within the thread, or return from the controlling function of the worker thread.For more information on AfxBeginThread, see the articlesMultithreading: Creating Worker Threads andMultithreading: Creating User-Interface Threads in Visual C++ Programmer’s Guide.See Also AfxGetThread
我用的是MFC的AfxBeginThread(SerialCOM,this),但是编译的时候还要说第一个参数不认识!
我这第一个参数明明是一个全局函数,而且参数为(LPVOID pParam),不明白!
自己Up
CWinThread* AfxBeginThread( AFX_THREADPROC pfnThreadProc, LPVOID pParam, int nPriority = THREAD_PRIORITY_NORMAL, UINT nStackSize = 0, DWORD dwCreateFlags = 0, LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL );CWinThread* AfxBeginThread( CRuntimeClass* pThreadClass, int nPriority = THREAD_PRIORITY_NORMAL, UINT nStackSize = 0, DWORD dwCreateFlags = 0, LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL );Return ValuePointer to the newly created thread object.ParameterspfnThreadProcPoints to the controlling function for the worker thread. Cannot be NULL. This function must be declared as follows:UINT MyControllingFunction( LPVOID pParam );pThreadClassThe RUNTIME_CLASS of an object derived from CWinThread.pParamParameter to be passed to the controlling function as shown in the parameter to the function declaration in pfnThreadProc.nPriorityThe desired priority of the thread. If 0, the same priority as the creating thread will be used. For a full list and description of the available priorities, seeSetThreadPriority in the Win32 Programmer’s Reference.nStackSizeSpecifies the size in bytes of the stack for the new thread. If 0, the stack size defaults to the same size stack as the creating thread.dwCreateFlagsSpecifies an additional flag that controls the creation of the thread. This flag can contain one of two values: CREATE_SUSPENDED Start the thread with a suspend count of one. The thread will not execute until ResumeThread is called.
0 Start the thread immediately after creation.
lpSecurityAttrsPoints to a SECURITY_ATTRIBUTES structure that specifies the security attributes for the thread. If NULL, the same security attributes as the creating thread will be used. For more information on this structure, see the Win32 Programmer’s Reference.ResCall this function to create a new thread. The first form of AfxBeginThread creates a worker thread. The second form creates a user-interface thread. AfxBeginThread creates a new CWinThread object, calls its CreateThread function to start executing the thread, and returns a pointer to the thread. Checks are made throughout the procedure to make sure all objects are deallocated properly should any part of the creation fail. To end the thread, call AfxEndThread from within the thread, or return from the controlling function of the worker thread.For more information on AfxBeginThread, see the articlesMultithreading: Creating Worker Threads andMultithreading: Creating User-Interface Threads in Visual C++ Programmer’s Guide.See Also AfxGetThread
现在编译通过了,可是鼠标一点击按钮或者悬浮于菜单上,程序就提示出错:(3个)0x0000000不能read,0x80000003出错,0x80000003出错!