#include <windows.h>
#include <stdio.h>LRESULT CALLBACK WinsunProc(
     HWND hwnd,
 UINT uMsg,
 WPARAM wParam,
 LPARAM lparam
)

int WinApi WinMain(                  //出问题的地方是这一行开始
hinstance hinstance,   
hinstance hprevinstance,
lpstr lpcmdline,
    int ncmdshow
)    
{
     wndclass wndcls;
 wndcls.cbclsextra=0;
 wndcls.cbwndextra=0;
 wndcls.hbrbackground=(hbrush)getstockobject(black_brush);
 wndcls.hcursor=loadcursor(null,idc_cross);
 wndcls.hicon=loadicon(null,idi_error);
 wndcls.hinstance=hinstance;
 wndcls.lpfnwndproc=winsunproc;
 wndcls.lpszclassname="weixin2008";
 wndcls.lpszmenuname=null;
 wndcls.style=cs_hredraw | cs_vredraw;
     registerclass(&wndcls);
 hwnd hwnd;
 hwnd=createwindow("weixin2003","维新学习",ws_overlappedwindow,0.0,600,400,null,null,hinstance,null);
 showwindow(hwnd,sw_shownormall);
 updatewindow(hwnd);  msg msg;
 while(getmessage(&msg,null,0,0)) 
 {
       Translatemessage(&msg);
   dispatchmessage(&msg);
 }
 return 0;
}    
LRESULT CALLBACK WinsunProc(
     HWND hwnd,
 UINT uMsg,
 WPARAM wParam,
 LPARAM lparam
)
{
     switch(uMsg)
 {
 case WM_CHAR:
 char szChar[20];
 sprintf(szChar,"char is %d",wParam);
 MessageBox(hwnd,szChar,"weixin",0);
 break;
 case WM_LBUTTONDOWN:
 MessageBox(hwnd,"mouse clicked","weixin",0);
 HDC hdc;
 hdc=GetDC(hwnd);
 TextOut(hdc,0.50,"计算机编程语言培训",strlen("计算机编程语言培训"));
 releaseDC(hwnd,hdc);
 break;
 case WM_PAINT:
 HDC hdc;
 PAINTSTRUCT ps;
 hdc=BeginPaint(hwnd,&ps);
 Textout(hDC,0,0,"维新培训",strlen("维新培训"));
 EndPaint(hwnd,&ps);
 break;
 case WM_CLOSE:
 if(IDYES==MessageBox(hwnd,"是否真的结束?","weixin",MB_YESNO))
 {
   DestroyWindow(hwnd);
 }
 break;
 case WM_DESTROY:
 PostQuitMessage(0);
 break;
 default:
 return DefwindowProc(hwnd,uMsg,wParam,lParam);
 }
 return 0;
}    --------------------Configuration: O1 - Win32 Debug--------------------
Compiling...
o1.cpp
E:\VCe\O1\o1.cpp(11) : warning C4518: 'int ' : storage-class or type specifier(s) unexpected here; ignored
E:\VCe\O1\o1.cpp(11) : error C2146: syntax error : missing ';' before identifier 'WinApi'
E:\VCe\O1\o1.cpp(11) : fatal error C1004: unexpected end of file found
Error executing cl.exe.O1.exe - 2 error(s), 1 warning(s)

解决方案 »

  1.   

    那就是抄错了,照理应该是WINAPI而不是WinApi,同样,后面是HINSTANCE而不是hinstance,是LPSTR而不是lpstr,是WNDCLASS而不是wndclass等,总之所有大写字母你都给改成小写了,不错才怪。
      

  2.   

    YES,区分大小写.
    努力吧,朋友!
      

  3.   

    YES,区分大小写.
    努力吧,朋友!
      

  4.   

    大小写问题还有就是要习惯使用 TCHAR 和 TEXT() ,或者就直接用unicode,WCHAR L"...."
      

  5.   

    像WinMain这样地函数建议楼主最好直接从MSDN拷贝。
      

  6.   

    很多书中都有源码的.如果不是大小写错误,就是这里
    hwnd=createwindow("weixin2003","维新学习",ws_overlappedwindow,0.0,600,400,null,null,hinstance,null); 
    showwindow(hwnd,sw_shownormall); 
    updatewindow(hwnd); 
    "维新学习",这个逗号写错了