《windows 98 程序设计从入门到精通》中第一个示例就有问题...
commu 2001-03-19 09:19:00 《windows 98 程序设计从入门到精通》P.13-P.14中的第一个示例如下所示:
#include <windows.h>
LRESULT CALLBACK WindowFunc(HWND,UINT,WPARAM,LPARAM);
char szWinName[]="MyWin"; /* name of window class */
int WINAPI WinMain(HINSTANCE hThisInst,HINSTANCE hPrevInst,LPSTR lpszArgs,int nWinMode)
{
HWND hwnd;
MSG msg;
WNDCLASSEX wcl;
/* Define a window class. */
wcl.cbSize=sizeof(WNDCLASSEX);
wcl.hInstance=hThisInst; /* handle to this instance */
wcl.lpszClassName=szWinName; /* window class name */
wcl.lpfnWndProc=WindowFunc; /* window function */
wcl.style=0; /* default style */
wcl.hIcon=LoadIcon(NULL,IDI_APPLICATION); /* standard icon */
wcl.hIconSm=LoadIcon(NULL,IDI_WINLOGO); /* small icon */
wcl.hCursor=LoadCursor(NULL,IDC_ARROW); /* cursor style */
wcl.lpszMenuName=NULL; /* no menu */
wcl.cbClsExtra=0; /* no extra information needed */
wcl.cbWndExtra=0; /* no extra information needed */
/* Make the window background white. */
wcl.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
/* Register the window class */
if(!RegisterClassEx(&wcl)) return 0;
/* Now that a window class has been registered,a window can be created. */
hwnd=CreateWindow(szWinName, /* name of window class */
"Window 98 Skeleton", /* title */
WS_OVERLAPPEDWINDOW,/* window style- normal */
CW_USEDEFAULT, /* X coordinate - let Windows decide */
CW_USEDEFAULT, /* Y coordinate - let Windows decide */
CW_USEDEFAULT, /* width - let Windows decide */
CW_USEDEFAULT, /* height - let Windows decide */
HWND_DESKTOP, /* no parent window */
NULL, /* no menu */
hThisInst, /* handle of this instance of the program */
NULL /* no additional arguments */
);
/* Display the window. */
ShowWindow(hwnd,nWinMode);
UpdateWindow(hwnd);
/* Create the message loop. */
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg); /* translate keyboard message */
DispatchMessage(&msg); /* return control to Window 98 */
}
return msg.wParam;
}
/* This function is called by Windows 98 and is passed messages from the message queue. */
LRESULT CALLBACK WindowFunc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message){
case WM_DESTROY: /* terminate the program */
PostQuitMessage(0);
break;
default:
/* Let Windows 98 process any messages not specified in the preceding switch statement. */
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0;
}
在VC6.0企业版中,编译通过,连接时报错:
Compiling...
Skipping... (no relevant changes detected)
abc.cpp
abc.obj - 0 error(s), 0 warning(s)
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/abc.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
abc.exe - 2 error(s), 0 warning(s)
不知上述两个是什么错误,VC6.0企业版是正版,在两台机器上均装了两遍,编译出现同样错误,请各位大侠能指点一下。