#include<afxwin.h>
#include<iostream>
UINT ThreadFunc(LPVOID param)
{
for (int i = 0; i < 5; i++)
{
char* p = (char*)param;
std::cout << p << std::endl;
Sleep(1000);
}
return 0;
}
int main()
{
CWinThread t(ThreadFunc, (char*)"线程1");
std::cout << "para:" << (char*)t.m_pThreadParams << std::endl;
t.m_bAutoDelete = false;
t.CreateThread();
WaitForSingleObject(t.m_hThread, INFINITE);
std::cout << "main 结束" << std::endl;
return 0;
}
运行失败,报错
fatal error C1189: #error: Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
解决办法: 成功运行
|