笨人请教(VC++)

来源:百度知道 编辑:UC知道 时间:2024/05/01 20:59:50
#include "stdafx.h"
#include "windows.h"

DWORD WINAPI Thread1(LPVOID lpParameter);

int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{

CreateThread(NULL,0,Thread1(),0,0,0);
return 0;
}

DWORD WINAPI Thread1(LPVOID lpParameter)
{

MessageBox (NULL,"Thread1!!","OK",MB_OK);
return 0;
}

第一次写c++,编译出错
error C2660: 'Thread1' : function does not take 0 parameters
请教请教
改了改 发现这样就能编译通过了
CreateThread(NULL,0,Thread1,0,0,0);
不过好像还有点问题

CreateThread(NULL,0,Thread1(),0,0,0);

这句里面Thread()要传一个参数,如果没有的话,比如你的情况,写成

CreateThread(NULL,0,Thread1(NULL),0,0,0); 就可以了

虽然不知道哪里错了,但是出错的语句的意思是参数不能返回0