【求助】windows下的c
这个程序的源码是在书上看到的 但总是运行不了 提示的是第26行 'RegisterClassEX'没有定义 郁闷 ------ 大家帮我看看到底是怎么回事啊
#include<windows.h>
INT PASCAL WinMain (HINSTANCE hinstance,HINSTANCE hPreinstance,LPSTR lpszCmdParam,INT nCmdShow);
LRESULT CALLBACK WndProc (HWND hMainwnd, UINT message, WPARAM wParam,LPARAM lParam);
INT PASCAL WinMain (HINSTANCE hinstance,HINSTANCE hPreinstance,LPSTR lpszCmdParam,INT nCmdShow)
{
HWND hMainwnd;
MSG message;
WNDCLASSEX myWC;
char szAppName[] = "test";
char szAppTitle[] = "用c语言编写的Windows程序";
if(!hPreinstance)
{
myWC.cbSize=sizeof(WNDCLASSEX);
myWC.style=CS_HREDRAW|CS_VREDRAW;
myWC.lpfnWndProc=WndProc;
myWC.cbClsExtra=0;
myWC.cbWndExtra=0;
myWC.hInstance=hinstance;
myWC.hIcon=LoadIcon(NULL,IDI_APPLICATION);
myWC.hCursor=LoadCursor(NULL,IDC_ARROW);
myWC.hIconSm=LoadIcon(NULL,IDI_WINLOGO);
myWC.hbrBackground=(HBRUSH)(GetStockObject(WHITE_BRUSH));
myWC.lpszMenuName=NULL;
myWC.lpszClassName=szAppName;
RegisterClassEX(&myWC); //这里出的问题
}
hMainwnd=CreateWindowEx(NULL,
szAppName, //窗口类名称
szAppTitle,//窗口标题
WS_OVERLAPPEDWINDOW,//窗口风格
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hinstance,//实例句柄
NULL);
ShowWindow(hMainwnd,SW_SHOWMAXIMIZED);
UpdateWindow(hMainwnd);
while(GetMessage(&message,NULL,0,0)) //从消息队列中取消息
{
TranslateMessage(&message); //转换消息
DispatchMessage(&message);//派发消息
}
return message.wParam;
}
LRESULT CALLBACK WndProc (HWND hMainwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
char message1[]="你按下了左键";
char message2[]="你按下了右键";
char message3[]="你按下了非系统键";
switch(message)
{
case WM_RBUTTONDOWN:
MessageBeep(MB_ICONINFORMATION);
MessageBox(GetFocus(),message2,"消息框",MB_OK|MB_ICONINFORMATION);
break;
case WM_LBUTTONDOWN:
MessageBeep(MB_ICONINFORMATION);
MessageBox(GetFocus(),message1,"消息框",MB_OK|MB_ICONINFORMATION);
break;
case WM_KEYDOWN:
MessageBeep(MB_ICONINFORMATION);
MessageBox(GetFocus(),message3,"消息框",MB_OK|MB_ICONINFORMATION);
break;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
break;
}
return DefWindowProc(hMainwnd,message,wParam,lParam);
}