大家帮我看看这么一个问题——————
编译时没错,但有一个WARNING!连接时错误如下:
Configuration: example1 - Win32 Debug--------------------
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/example1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
example1.exe - 2 error(s), 0 warning(s)
源代码如下:(
#include "stdafx.h"
//#include "stdlib.h"
//#include "string.h"
long WINAPI WndProc(HWND,UINT,UINT,LONG);
//void WINAPI CaretPos(int *xCaret,int *yCaret);
bool InitWindowsClass(HINSTANCE hInstance);
bool InitWindows(HINSTANCE hInstance,int nCmdShow);
HWND hWndMain;
//Ö÷º¯Êý
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
MSG Message;
if(! InitWindowsClass(hInstance))
{
MessageBeep(0);
return false;
}
if(! InitWindows(hInstance,nCmdShow))
return false;
//ShowWindow(hwnd,nCmdShow);
//
while(GetMessage(&Message,NULL,0,0))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return Message.wParam;
}
//
long WINAPI WndProc(HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0);
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return(0);
}
bool InitWindowsClass(HINSTANCE hInstance)
{
WNDCLASS wndclass;
wndclass.style=CS_HREDRAW|CS_VREDRAW;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(NULL,"END");
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName="winkeyboard";
return (RegisterClass(&wndclass));
}
bool InitWindows(HINSTANCE hInstance,int nCmdShow)
{
HWND hwnd ;
hwnd=CreateWindow("winkeyboard",
"¼üÅ̲Ù×÷Àý×Ó",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
0,
CW_USEDEFAULT,
0,
NULL,
NULL,
hInstance,
NULL);
if(!hwnd)
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
return true;
}