本人刚学习vc依葫芦画瓢编了一段简单的代码
连接的时候总是出现错误
linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/4_5.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
4_5.exe - 2 error(s), 0 warning(s)
麻烦各位高手帮我看看,那里出错了啊?
#include<windows.h>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
LRESULT CALLBACK WinPro(HWND,UINT,WPARAM,LPARAM);
int WINAPI winmain(HINSTANCE hinstance,
HINSTANCE prehinst,
LPSTR lpline,
int ncmdshow
)
{
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
char lpclassname[]="lizi";
char lptitle[]="事例1";
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.style=0;
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hInstance=hinstance;
wndclass.lpfnWndProc=WinPro;
wndclass.lpszClassName=lpclassname;
wndclass.lpszMenuName=NULL;
if(!RegisterClass(&wndclass))
{
MessageBeep(0);
return FALSE;
}
hwnd=CreateWindow
(
lpclassname,
lptitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hinstance,
NULL
);
ShowWindow(hwnd,ncmdshow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WinPro(
HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam
)
{
HDC hdc;
PAINTSTRUCT ps;
HPEN hp;
// HBRUSH hb;
POINT pt[5]={{10,15},{25,33},{10,33},{25,60},{40,55}};
switch(message)
{
case WM_PAINT:
hp=CreatePen(PS_SOLID,2,RGB(255,0,0));
hdc=BeginPaint(hwnd,&ps);
SetMapMode(hdc,MM_TEXT);
//Polygon(hdc,&pt[5],5);// msdn
EndPaint(hwnd,&ps);
break;
case WM_DESTROY:
DeleteObject(hp);
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0;
}