// thread.cpp : Defines the entry point for the application.
//#include "stdafx.h"
#include <windows.h>DWORD WINAPI MOMTThread(PVOID pParam)
{
//
MessageBox(NULL,"测试","Caption",MB_OK);
return 0;
}DWORD WINAPI MTThread(PVOID pParam)
{
//
return 0;
}int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
  // TODO: Place code here.
CreateThread(NULL,0,MOMTThread,NULL,0,NULL); return 0;
}真是奇怪了,我断点设在MessageBox(NULL,"测试","Caption",MB_OK);这一行,也停不下来。整个程序好像一运行就退出了

解决方案 »

  1.   

    晕,程序没退出,不过你主线程结束倒是真的。int APIENTRY WinMain(HINSTANCE hInstance,
                         HINSTANCE hPrevInstance,
                         LPSTR     lpCmdLine,
                         int       nCmdShow)
    {
      // TODO: Place code here.
    CreateThread(NULL,0,MOMTThread,NULL,0,NULL);
    return 0;
    }
      

  2.   

    在CreateThread之后加个while(true)
    {
       sleep(1);
    }应该能看到断点了
      

  3.   

    还没等MessageBox(NULL,"测试","Caption",MB_OK),主线程已经结束了。int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]){
      CreateThread(NULL,0,MOMTThread,NULL,0,NULL); while(1)
    {
    Sleep(10);
    }
    return 0;
    }就行了。