WinMain()重载错误
梵净游云 2008-11-23 03:19:45 各位高人,你们好!我是一个vc初学者,在使用VC2005编译一个win32 application 程序的时候提示error C2731: 'WinMain' : function cannot be overloaded 。 第一次写windows程序就遇到这么个问题,很久都没想出是什么原因引起的,郁闷死了!希望高人们不吝指点,不胜感激!
『注』:该程序在VC6.0中能正常编译执行。
程序代码如下:
#include "windows.h"
LRESULT CALLBACK WindowProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPWSTR lpCmdLine,
int nShowCmd
)
{
static LPCTSTR szAPPNAME=L"hulin";
WNDCLASSEX window;
MSG msg;
HWND hwnd;
window.cbClsExtra=0;
window.cbSize=sizeof(WNDCLASSEX);
window.cbWndExtra=0;
window.hbrBackground=static_cast<HBRUSH>(GetStockObject(LTGRAY_BRUSH));
window.hCursor=NULL;
window.hIcon=NULL;
window.hIconSm=NULL;
window.hInstance=hInstance;
window.lpfnWndProc=WindowProc;
window.lpszClassName=szAPPNAME;
window.lpszMenuName=0;
window.style=CS_HREDRAW | CS_VREDRAW;
RegisterClassEx(&window);
hwnd=CreateWindow(szAPPNAME,L"菜鸟第一次",WS_OVERLAPPEDWINDOW,0,50,400,600,0,0,hInstance,0);
ShowWindow(hwnd,SW_SHOW);
UpdateWindow(hwnd);
while(1==GetMessage(&msg,0,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return static_cast <int>(msg.wParam);
}