📄 subject_20372.htm
字号:
<p>
序号:20372 发表者:jackyang 发表日期:2002-11-05 23:41:30
<br>主题:关于一个VC程序调试的问题。
<br>内容:#include <windows.h><BR>LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);<BR>int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)<BR>{<BR> static TCHAR szAppName[]=TEXT("HelloWin");<BR> static TCHAR szClassName[]=TEXT("HelloWinClass");<BR> HWND hwnd;<BR> MSG msg;<BR> WNDCLASS wndclass;<BR> wndclass.style=CS_HREDRAW|CS_VREDRAW;<BR> wndclass.lpfnWndProc=WndProc;<BR> wndclass.cbClsExtra=0;<BR> wndclass.cbWndExtra=0;<BR> wndclass.hInstance=hInstance;<BR> wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);<BR> wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);<BR> wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);<BR> wndclass.lpszMenuName=NULL;<BR> wndclass.lpszClassName=szClassName;<BR> if(!RegisterClass(&wndclass))<BR> {<BR> MessageBox(NULL,TEXT("This program require Windows NT!"),szAppName,MB_ICONERROR);<BR> return 0;<BR> }<BR> hwnd=CreateWindow(szClassName,TEXT("The HelloWin Program"),<BR> WS_OVERLAPPEDWINDOW,<BR> CW_USEDEFAULT,<BR> CW_USEDEFAULT,<BR> CW_USEDEFAULT,<BR> CW_USEDEFAULT,<BR> NULL,<BR> NULL,<BR> hInstance,<BR> NULL);<BR> ShowWindow(hwnd,nCmdShow);<BR> UpdateWindow(hwnd);<BR> while (GetMessage(&msg,NULL,0,0))<BR> {<BR> TranslateMessage(&msg);<BR> DispatchMessage(&msg);<BR> }<BR> return msg.wParam;<BR>}<BR>LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)<BR>{<BR> HDC hdc;<BR> PAINTSTRUCT ps;<BR> RECT rect;<BR> switch(message)<BR> {<BR> case WM_CREATE:<BR> MessageBox(NULL,"Create... ...","HelloWinMessage:",MB_OK);<BR> return 0;<BR> case WM_PAINT: <BR> hdc=BeginPaint(hwnd,&ps);<BR> GetClientRect(hwnd,&rect);<BR> DrawText(hdc,TEXT("Hello,Windows 98!"),-1,&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);<BR> EndPaint(hwnd,&ps);<BR> return 0;<BR> case WM_DESTROY:<BR> PostQuitMessage(0);<BR> return 0;<BR> }<BR> return DefWindowProc(hwnd,message,wParam,lParam);<BR>}<BR>上面这个程序编译可以通过,但执行时发生错误,有如下错误提示:“Linking...<BR>LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main<BR>Debug/hello.exe : fatal error LNK1120: 1 unresolved externals<BR>Error executing link.exe.”请那位大虾帮忙解决一下。<BR><BR><BR>
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:John Lan 回复日期:2002-11-05 23:53:27
<br>内容:did u create a *console* project ? if so, create a new *win32* project<BR>_main() is for console project, NOT for win32 project.
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:了了 回复日期:2002-11-06 09:18:30
<br>内容:http://www.vchelp.net/cndevforum/subject_view.asp?subject_id=11499&forum_id=
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:晚风也渡 回复日期:2002-11-06 12:59:08
<br>内容:我编译了,没有问题,能够通过。<BR>我想你可能建立的工程不对,因为应该建立一个win32的工程,你是不是建立的别的工程?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -