
请帮忙看一下这个C++程序有什么错误
这是一个project里的一个文件:#include<windows.h>#include<stdio.h>LRESULTCALLBACKWinSunProc(HWNDh...
这是一个project里的一个文件:
#include <windows.h>
#include <stdio.h>
LRESULT CALLBACK WinSunProc
(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);
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="ytp";
wndcls.lpszMenuName=NULL;
wndcls.style=CS_HREDRAW | CS_VREDRAW;
RegisterClass (&wndcls);
HWND hwnd;
hwnd=CreateWindow ("ytp","tianpengyuanshuai",WS_OVERLAPPEDWINDOW,0,0,600,400,NULL,NULL,hInstance,NULL);
ShowWindow (hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
MSG msg;
while (GetMessage (&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WinSunProc
(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch (uMsg)
{
case WM_CHAR:
char szChar[20];
sprintf(szChar,"char is %d",wParam);
MessageBox(hwnd,szChar,"ytp",0);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"mouse click","ytp",0);
HDC hdc;
hdc=GetDC(hwnd);
TextOut(hdc,0,50,"ytp is trying",strlen("ytp is trying"));
ReleaseDC(hwnd,hdc);
break;
case WM_PAINT:
HDC hDc;
PAINTSTRUCT ps;
hDc = BeginPaint(hwnd,&ps);
TextOut(hDc,0,0,"ytp",strlen("ytp"));
EndPaint (hwnd,&ps);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"Sure ZTo Close?","ytp",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc (hwnd,uMsg,wParam,lParam);
}
return 0;
}
链接的时候
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/winmain.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.
请大家帮忙看一下 谢谢
所建的工程是Win32 Application 展开
#include <windows.h>
#include <stdio.h>
LRESULT CALLBACK WinSunProc
(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);
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="ytp";
wndcls.lpszMenuName=NULL;
wndcls.style=CS_HREDRAW | CS_VREDRAW;
RegisterClass (&wndcls);
HWND hwnd;
hwnd=CreateWindow ("ytp","tianpengyuanshuai",WS_OVERLAPPEDWINDOW,0,0,600,400,NULL,NULL,hInstance,NULL);
ShowWindow (hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
MSG msg;
while (GetMessage (&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WinSunProc
(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch (uMsg)
{
case WM_CHAR:
char szChar[20];
sprintf(szChar,"char is %d",wParam);
MessageBox(hwnd,szChar,"ytp",0);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"mouse click","ytp",0);
HDC hdc;
hdc=GetDC(hwnd);
TextOut(hdc,0,50,"ytp is trying",strlen("ytp is trying"));
ReleaseDC(hwnd,hdc);
break;
case WM_PAINT:
HDC hDc;
PAINTSTRUCT ps;
hDc = BeginPaint(hwnd,&ps);
TextOut(hDc,0,0,"ytp",strlen("ytp"));
EndPaint (hwnd,&ps);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"Sure ZTo Close?","ytp",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc (hwnd,uMsg,wParam,lParam);
}
return 0;
}
链接的时候
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/winmain.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.
请大家帮忙看一下 谢谢
所建的工程是Win32 Application 展开
2个回答
展开全部
可能建错项目了
http://hi.baidu.com/%B4%C5%C1%F7/blog/item/9c4dd1df6db45a1b49540390.html这个网址将得比较全面自己去看下吧
http://hi.baidu.com/%B4%C5%C1%F7/blog/item/9c4dd1df6db45a1b49540390.html这个网址将得比较全面自己去看下吧
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询