论坛: 编程破解 标题: 自己用VC++6.0编了个程序,有2个错误怎样都改不好!!!!急急急急 复制本贴地址    
作者: luokaixuan [luokaixuan]    论坛用户   登录
Compiling...
winmain.cpp
D:\新建文件夹1\less0n1\winmain\winmain.cpp(16) : error C2447: missing function header (old-style formal list?)
D:\新建文件夹1\less0n1\winmain\winmain.cpp(51) : error C2447: missing function header (old-style formal list?)
Error executing cl.exe.

winmain.obj - 2 error(s), 0 warning(s)
程序如下:

#include <windows.h>
#include <stdio.h>
LRESULT CALLBACK Winsunproc(
  HWND hwnd,      // handle to window
  UINT uMsg,      // message identifier
  WPARAM wParam,  // first message parameter
  LPARAM lParam  // second message parameter
);
int WINAPI WinMain(
  HINSTANCE hInstance,            // handle to current instance
  HINSTANCE hPrevInstance,        // handle to previous instance
  LPSTR lpCmdLine,                // pointer to command line
  int nCmdShow                  // show state of window
);
{
WNDCLASS  wndcls;                            //设计一个窗口类
              wndcls.style=CS_HREDRAW|CS_VREDRAW;
              wndcls.lpfnWndProc=Winsunproc;
  wndcls.cbClsExtra=0;
  wndcls.cbWndExtra=0;
  wndcls.hInstance=hInstance;
  wndcls.hIcon=LoadIcon(NULL,IDI_ERROR);
  wndcls.hCursor=LoadCursor(NULL,IDC_CROSS);
              wndcls.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
              wndcls.lpszMenuName=NULL;
              wndcls.lpszClassName="weixin";
  Registerclass(&wndcls);      //注册一个窗口类
 
  HWND  hwnd;                    //创建一个窗口
  hwnd=CreateWindow("weixin","北京维新科学技术中心",
                WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,
750,500,NULL,NULL,hInstance,NULL);

ShowWindow(hWnd,SW_SHOWNORMAL);  //显示及更新一个窗口
Updatewindow(hWnd);
MSG  msg;                            //消息循环
While(Getmessage(&msg,NULL,0,0))
{
Translatemessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK Winsunproc(
  HWND hwnd,      // handle to window
  UINT uMsg,      // message identifier
  WPARAM wParam,  // first message parameter
  LPARAM lParam  // second message parameter
);
{
switch(uMsg)
{
case WM_CHAR:
char szchar[20];
sprintf(szchar,"char is d% ",wParam);
MessageBox(hwnd,szchar,"weixin",MB_OK);
break;
case WM_LBUTTONDOWN:
        MessageBox(hwnd,"Mouse clicked",MB_OK);
HDC hdc;       
hdc=GetDC(hwnd);            //获取一个"DC"的句柄,表示和“hwnd”这个窗口相关的“DC”
Textout(hdc,0,50,"计算机语言培训",strlen("计算机语言培训"));
Release(hwnd,hdc);
break;
case WM_PAINT:
HDC hDc;
        PAINTSTRUCT PS;
        hDc=Beginpaint(hwnd,&PS);
        Textout(hDc,0,50,"第一次用编程",strlen("第一次用编程"));
Endpaint(hwnd,&PS);
        break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"你是否真的结束?","weixin",MB_YESNO))
{
DestroyWindow(hwnd);    //此函数关闭窗口同时送出一个“WM-DESTROY”和WM-NCDESTROY给窗口
}
break;
case WM_DESTROY:
PostQuitMessage(0);  //此函数会投递一个WM-Quit到线程队列当中,然后立即返回。
                      //而前边的Getmessage()函数收到WM-QUIT消息时,返回值为0,那个WHile()终止循环
break;
default:
return  DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}
Sample Text

地主 发表时间: 11-05-02 21:05

回复: NetDemon [netdemon]   ADMIN   登录
说得很明白了啊 missing function header 
这个错误通常是因为函数的函数头后边加了分号引起

int WINAPI WinMain(
  HINSTANCE hInstance,            // handle to current instance
  HINSTANCE hPrevInstance,        // handle to previous instance
  LPSTR lpCmdLine,                // pointer to command line
  int nCmdShow                  // show state of window
); <-------去掉这个分号
{
WNDCLASS  wndcls;                            //设计一个窗口类
              wndcls.style=CS_HREDRAW|CS_VREDRAW;
              wndcls.lpfnWndProc=Winsunproc;
  wndcls.cbClsExtra=0;


[此贴被 NetDemon(netdemon) 在 05月03日00时07分 编辑过]

B1层 发表时间: 11-05-02 23:54

论坛: 编程破解

20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon

粤ICP备05087286号