#include <windows.h>//窗口函数说明
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);//初始化窗口类
//WinMain函数说明
int WINAPI WinMain( HINSTANCE hInstance,HINSTANCE hPrevInst, LPSTR lpszCmdLine, int nCmdShow)
{
HWND hwnd ;
MSG Msg ;
WNDCLASS wndclass ;
char lpszClassName[] = "窗口"; //窗口类名
char lpszTitle[]= "My_Windows"; //窗口标题名        //窗口类的定义
wndclass.style = 0; //窗口类型为缺省类型
wndclass.lpfnWndProc = WndProc ; //窗口处理函数为WndProc
wndclass.cbClsExtra = 0 ; //窗口类无扩展
wndclass.cbWndExtra = 0 ; //窗口实例无扩展
wndclass.hInstance = hInstance ; //当前实例句柄
wndclass.hIcon = LoadIcon( NULL, IDI_APPLICATION) ;
//窗口的最小化图标为缺省图标
wndclass.hCursor = LoadCursor( NULL, IDC_ARROW) ;
//窗口采用箭头光标
wndclass.hbrBackground = GetStockObject( WHITE_BRUSH) ;
//窗口背景为白色
wndclass.lpszMenuName = NULL ; //窗口中无菜单
wndclass.lpszClassName = lpszClassName ;
//窗口类名为"窗口示例" //窗口类注册
    if( !RegisterClass( &wndclass)) //如果注册失败则发出警告声音
{
MessageBeep(0) ;
return FALSE ;
}        //创建窗口
hwnd=CreateWindow(lpszClassName, //窗口类名
lpszTitle, //窗口实例的标题名
WS_OVERLAPPEDWINDOW,//窗口的风格
CW_USEDEFAULT,
CW_USEDEFAULT, //窗口左上角坐标为缺省值
CW_USEDEFAULT,
CW_USEDEFAULT,, //窗口的高和宽为缺省值
NULL, //此窗口无父窗口
NULL, //此窗口无主菜单
hInstance, //创建此窗口的应用程序的当前句柄
NULL) ; //不使用该值 //显示窗口
ShowWindow( hwnd, nCmdShow) ;
//绘制用户区
UpdateWindow(hwnd);
//消息循环 
while( GetMessage(&Msg, NULL, 0, 0))
{
TranslateMessage( &Msg) ;
DispatchMessage( &Msg) ;
} return Msg.wParam; //消息循环结束即程序终止时将信息返回系统
}//窗口函数
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM  wParam, LPARAM  lParam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0); //调用PostQuitMessage发出WM_QUIT消息 default: //默认时采用系统消息默认处理函数
return  DefWindowProc(hwnd,message,wParam,lParam);
}
return (0);
}
//////////////////////////////////////////////////////////////
linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/3-1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.3-1.exe - 2 error(s), 0 warning(s)

解决方案 »

  1.   

    好像是提示你缺少静态连接文件也就是lib文件或者把你的回调函数的声明去掉try
      

  2.   

    新建工程选择类型不对,应选择WIn32 Application建工程,并加入上面的代码
      

  3.   

    还是不可以阿 
    这个程序是光盘上的程序,我在vc++6.0中编译就出现这样了
    可是只有使用原来的dsw文件才可以正确运行
      

  4.   

    E:\vc\why\why.cpp(26) : error C2440: '=' : cannot convert from 'void *' to 'struct HBRUSH__ *'
            Conversion from 'void*' to pointer to non-'void' requires an explicit cast
    Error executing cl.exe.why.exe - 1 error(s), 0 warning(s)
      

  5.   

    我找到了一个办法。
    wndclass.hbrBackground =CreateSolidBrush(RGB(255,255,255));
      

  6.   

    算了,放了好久了
    就这样结了吧
    谢谢 Pipi0714(皮皮0714)   
    和hanwg()