AfxGetThread

调用此函数得到指向CWinThread的指针表示当前执行的线程的对象。

CWinThread* AfxGetThread( );

返回值

对当前执行的线程的指针;否则为 NULL

备注

必须从所需线程内部调用。

备注

如果迁移 MFC 项目从 Visual C++ 版本 4.2、5.0 或 6.0,则 AfxGetThreadAfxGetThread,调用 AfxGetApp,如果线程未找到。在可视化对象 C+ .NET 和更高版本,AfxGetThread 返回 NULL,则线程未找到。如果希望应用程序线程,必须调用 AfxGetApp

示例

//Print the current thread ID in the Debug Window
TRACE(_T("Current Thread ID = 0x%X\n"), AfxGetThread()->m_nThreadID);

要求

标头: afxwin.h

请参见

参考

AfxBeginThread

概念

MFC 宏和全局函数