首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

写的一个windows的窗口出现如上异常,求大神解答

2013-01-04 
写的一个windows的窗口出现如下错误,求大神解答#include windows.h// include the basic windows header

写的一个windows的窗口出现如下错误,求大神解答
#include <windows.h>    // include the basic windows header file

// the entry point for any Windows program
int WINAPI WinMain(HINSTANCE hInstance,
                   HINSTANCE hPrevInstance,
                   LPSTR lpCmdLine,
                   int nShowCmd)
{
    // create a "Hello World" message box using MessageBox()
    MessageBox(NULL,
               L"Hello World!",
               L"Just another Hello World program!",
               MB_ICONEXCLAMATION | MB_OK);

    // return 0 to Windows
    return 0;
}
错误:
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: 无法解析的外部符号 _main,该符号在函数 ___tmainCRTStartup 中被引用
1>D:\3dgame\3dgame\Debug\3dgame.exe : fatal error LNK1120: 1 个无法解析的外部命令
[解决办法]
建立工程的时候选择项目错了,应该是建立一个WIN32 Application  而不是我们平时写C++程序时候建立的那个WIN32 Console Application   Win32 Application默认的程序入口是int WINAPI WinMain(HINSTANCE hInstance,
  HINSTANCE hPrevInstance,
  LPSTR lpCmdLine,
  int nShowCmd)这个,而Win32 Console Application 默认的程序入口才是main()


我也是一个菜鸟,以后还希望各位大虾们多多照顾哟!!!

热点排行