VC中的疑惑

来源:百度知道 编辑:UC知道 时间:2024/06/30 01:06:14
#include <windows.h>
#include <stdio.h>

LRESULT CALLBACK WinSunProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);

int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
WNDCLASS wndcls;
wndcls.cbClsExtra=0;
wndcls.cbWndExtra=0;
wndcls.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wndcls.hCursor=LoadCursor(NULL,IDC_CROSS);
wndcls.hIcon=LoadIcon(NULL,IDI_ERROR);
wndcls.hInstance=hInstance;
wndcls.lpfnWndProc=WinSunProc;
wndcls.lpszClassName="Weixin2003";
wndcls.lpszMenuName=NULL;
wndcls.style=CS_HREDRAW | CS_VREDRAW;

我前天刚刚犯过同样的错误,新手错误呀!老手都不一定见过!HOHO!下面是我的经验总结记录:
=====================================================================
--------------------Configuration: huaxian - Win32 Debug--------------------
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/huaxian.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.

huaxian.exe - 1 error(s), 0 warning(s)
出错现象:Compile(编译Ctrl+F7)正常,但Build(构造F7)出错
出错原因:建立应用程序框架时出错.
1.不能只建立C++源文件,后创建工程,再Build
2.创建win32 Application工程时,只能创建一个空工程,然后再新建一个C++源文件
心得体会:
1、当complie成功而Build出错时,可断定不是代码输入出错。
2、例题如果没有指出用MFC建立应用程序框架或语句中大量使用API、GDI、句柄等window语句时,可断定为win32 Application工程
=====================

又是你啊——维新培训!呵呵,好久不见,我记得当时不是把正确的代码发给你了?怎么又有问题了?
那句提示说有个main()函数?你这是Win32工程,不要有main啊!