if( !CreateProcess( NULL, // No module name (use command line).
TEXT("test.exe"), // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi) // Pointer to PROCESS_INFORMATION structure.
)
{
MessageBox("启动失败!");
exit(-1);
}
DWORD WINAPI ThreadFunc1(LPVOID lpmess); //声明线程实现的函数
HANDLE hThread; //创建一个线程句柄
char *mess; //创建一个字符串变量
mess="Hello Thread!"; //习惯了c#,java的string类以后用这个真是不太舒服
hThread=CreateThread(NULL,0,ThreadFunc1,mess,0,NULL); //成功的话返回一个县城句柄
DWORD WINAPI ThreadFunc1(LPVOID lpmess) //一定要符合这种规范
{
char *mess;
mess = (char *)lpmess; //因为穿过来的是LPVOID类型的,所以一定要进行类型转换
MessageBox(NULL,mess,"Message",NULL);
return 0; //最后不要忘记返回一个DWORD
}