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

小弟我这段程序为什么编译不过去

2012-02-04 
我这段程序为什么编译不过去啊首先我已经在link-》input-》additionaldependencies加载了Ws2_32.lib,可是编

我这段程序为什么编译不过去啊
首先我已经在link-》input-》additional   dependencies加载了Ws2_32.lib,可是编译不过去,我用vs2005,不知道为什么
#include <windows.h>
#include <Winsock2.h>
LRESULT   CALLBACK   WndProc
(   HWND   hwnd,
    UINT   uMsg,
    WPARAM   wParam,
    LPARAM   lParam
);
int   WINAPI   WinMain(HINSTANCE   hInstance,
        HINSTANCE   hPrevInstance,
        LPSTR   lpCmdLine,
        int   nCmdShow
)
{
WNDCLASS   wc;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hbrBackground=(HBRUSH)::GetStockObject(WHITE_BRUSH);
wc.hCursor=::LoadCursor(NULL,IDC_ARROW);
wc.hInstance=hInstance;
wc.lpfnWndProc=WndProc;
wc.lpszClassName= "Draw ";
wc.lpszMenuName=NULL;
wc.hIcon   =   LoadIcon   (NULL,   IDI_APPLICATION);
wc.style=CS_HREDRAW   |   CS_VREDRAW;
if(!RegisterClass(&wc))
{
::MessageBox(NULL, "窗口注册失败 ", "提示 ",MB_OK);
}
HWND   hwnd=::CreateWindow( "Draw ", "画图板 ",WS_OVERLAPPEDWINDOW   ,
                                    CW_USEDEFAULT,   CW_USEDEFAULT,
                                                    CW_USEDEFAULT,   CW_USEDEFAULT,
                                                    NULL,   NULL,   hInstance,   NULL)   ;
::ShowWindow(hwnd,nCmdShow);
::UpdateWindow(hwnd);
MSG   msg;
while(GetMessage(&msg,NULL,0,0))
{
    TranslateMessage   (&msg)   ;
                    DispatchMessage   (&msg)   ;
}
return   msg.wParam;
}
LRESULT   CALLBACK   WndProc
(   HWND   hwnd,
    UINT   uMsg,
    WPARAM   wParam,
    LPARAM   lParam
)
{
        HDC   hdc;
PAINTSTRUCT   ps;
WORD   wVersionRequested;
WSADATA   wsaData;
int   err;
wVersionRequested   =   MAKEWORD(1,1);
err   =   WSAStartup(   wVersionRequested,   &wsaData   );
if   (   err   !=   0   )
{                                            
return   0;
}
if   (   LOBYTE(wsaData.wVersion)!=   1   ||
HIBYTE(wsaData.wVersion)!=   1   )  
{                                                        
WSACleanup(   );
return   0;  
}

switch(uMsg)
{
case   WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
::EndPaint(hwnd,&ps);
return   0;
case   WM_DESTROY:
PostQuitMessage(0);
return   0;
case   WM_CHAR:

default:
return   ::DefWindowProc(hwnd,uMsg,wParam,lParam);


}
}



[解决办法]
报什么错,从错误信息中看不出问题吗?
[解决办法]
#include <Winsock2.h>
#include <windows.h>

更改包含顺序

热点排行