现在的位置: 首页 > 综合 > 正文

MFC创建线程01 AfxBeginThread

2018年10月04日 ⁄ 综合 ⁄ 共 350字 ⁄ 字号 评论关闭

 

//Step 0  设置 “在共享DLL中使用MFC”

//Step 1  包含头文件< afxwin.h>
#include <afxwin.h>
#include <iostream>
using namespace std;

//Step 3 线程函数 返回值、参数
UINT ThreadProc(LPVOID)
{
	for(int i=0;i<10;i++)
		cout<<i<<endl;

	return 0;
}

void main(int argc,TCHAR*argv[])
{
	//Step 2  CWinThread  AfxBeginThread()
	CWinThread *pThread = AfxBeginThread(ThreadProc,NULL);

	Sleep(1000);

	//Step 4 CWinThread自动delete、CloseHandle()
}

抱歉!评论已关闭.