源程序:
#include "windows.h"
#include "stdio.h"LRESULT CALLBACK WindowSunProc(HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
)
{
WNDCLASS wndcls;
wndcls.cbClsExtra=0;
wndcls.cbWndExtra=0;
wndcls.hbrBackground=(HBRUSH)GetStockObject(BLACK_PEN);
wndcls.hCursor=LoadCursor(NULL,IDC_HELP);
wndcls.hIcon=LoadIcon(NULL,IDI_HAND);
wndcls.hInstance=hInstance;
wndcls.lpfnWndProc=WindowSunProc;
wndcls.lpszClassName="zqClass";
wndcls.lpszMenuName=NULL;
wndcls.style=CS_VREDRAW|CS_HREDRAW;

RegisterClass(&wndcls);
HWND hwnd;
hwnd=CreateWindow("zqClass","哥的一个程序",WS_OVERLAPPEDWINDOW,
 0,0,600,400,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);

MSG msg;
while (GetMessage(&msg,hwnd,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WindowSunProc(HWND hwnd,
   UINT uMsg,
   WPARAM wParam,
   LPARAM lParam
   )
{
switch(uMsg) {
case WM_CHAR:
char zqChar[20];
sprintf(zqChar,"Char is %d",wParam);
MessageBox(hwnd,zqChar,"zqzq",0);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"DOWN","zq1",0);
HDC hdc;
hdc=GetDC(hwnd);
TextOut(hdc,0,50,"合肥工业大学",strlen("合肥工业大学"));
ReleaseDC(hwnd,hdc);
break;
case WM_PAINT:
HDC hdcz;
PAINTSTRUCT ps;
hdcz = BeginPaint(hwnd,&ps);
TextOut(hdc,0,100,"1111",strlen("1111"));
EndPaint(hwnd,&ps);
break;
case WM_CLOSE:
if (IDYES==MessageBox(hwnd,"QUIT?!~~","quit",MB_YESNO)) 
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}点下BUILD后出现的信息--------------------Configuration: first - Win32 Release--------------------
Linking...
LIBC.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Release/first.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Creating browse info file...first.exe - 2 error(s), 0 warning(s)
这是怎么回事哎,谢谢各位了

解决方案 »

  1.   

    你的工具类型是控制台的,改为win32
      

  2.   

    在工程设置Command line中把/SUBSYSTEM:CONSOLE改为/SUBSYSTEM:WINDOWS
      

  3.   

    还有个笨办法:重建一个工程,在类型里选择Win32 Appcation,再输入代码。你肯定选的是Win32 Consle类型才出现这样的状况的。
      

  4.   

    看《Windows 程序设计》。看前四章就可以大概掌握了。
      

  5.   

    建错工程类型了,不要建console的工程,间win32 applications的工程