📄 subject_42812.htm
字号:
<p>
序号:42812 发表者:Taid 发表日期:2003-06-06 00:25:39
<br>主题:如何在命令行方式调试运行HelloWin程序?
<br>内容:这是侯sir《Programming Windows with MFC 2nd》中的一个小程序<BR>我想通过命令行下的\cl HelloWin.c来编译,提示:<BR> error LNK2001: unresolved external symbol __imp_×(※……%98<BR><BR>等等错误信息,可能是一些库没有设置,能告诉加入哪些参数来编译吗?<BR>BTW:在VC中新建project并且setting中添加了WINMM.LIB 编译运行成功<BR><BR>鞋鞋。。。。。<BR><BR><BR><BR>HELLOWIN.C<BR>/*------------------------------------------------------------------------<BR> HELLOWIN.C -- Displays "Hello, Windows 98!" in client area<BR> (c) Charles Petzold, 1998<BR> -----------------------------------------------------------------------*/<BR><BR>#include <windows.h><BR><BR>LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;<BR><BR>int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,<BR> PSTR szCmdLine, int iCmdShow)<BR>{<BR> static TCHAR szAppName[] = TEXT ("HelloWin") ;<BR> HWND hwnd ;<BR> MSG msg ;<BR> WNDCLAS wndclass ;<BR><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.lpszMenuNam = NULL ;<BR> wndclass.lpszClassName = szAppName ;<BR><BR> if (!RegisterClass (&wndclass))<BR> {<BR> MessageBox ( NULL, TEXT ("This program requires Windows NT!"), <BR> szAppName, MB_ICONERROR) ;<BR> return 0 ;<BR> }<BR> hwnd = CreateWindow( szAppName, // window class name<BR> TEXT ("The Hello Program"), // window caption<BR> WS_OVERLAPPEDWINDOW, // window style<BR> CW_USEDEFAULT, // initial x position<BR> CW_USEDEFAULT, // initial y position<BR> CW_USEDEFAULT, // initial x size<BR> CW_USEDEFAULT, // initial y size<BR> NULL, // parent window handle<BR> NULL, // window menu handle<BR> hInstance, // program instance handle<BR> NULL) ; // creation parameters<BR> <BR> ShowWindow (hwnd, iCmdShow) ;<BR> UpdateWindow (hwnd) ;<BR> <BR> while (GetMessage (&msg, NULL, 0, 0))<BR> {<BR> TranslateMessage (&msg) ;<BR> DispatchMessage (&msg) ;<BR> }<BR> return msg.wParam ;<BR>}<BR><BR>LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)<BR>{<BR> HDC hdc ;<BR> PAINTSTRUCT ps ;<BR> RECT rect ;<BR> <BR> switch (message)<BR> {<BR> case WM_CREATE:<BR> PlaySound (TEXT ("hellowin.wav"), NULL, SND_FILENAME | SND_ASYNC) ;<BR> return 0 ;<BR><BR> case WM_PAINT:<BR> hdc = BeginPaint (hwnd, &ps) ;<BR> <BR> GetClientRect (hwnd, &rect) ;<BR> <BR> DrawText (hdc, TEXT ("Hello, Windows 98!"), -1, &rect,<BR> DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;<BR> EndPaint (hwnd, &ps) ;<BR> return 0 ;<BR> <BR> case WM_DESTROY:<BR> PostQuitMessage (0) ;<BR> return 0 ;<BR> }<BR> return DefWindowProc (hwnd, message, wParam, lParam) ;<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>
<font color=red>答案被接受</font><br>回复者:Neil Gan 回复日期:2003-06-06 08:45:18
<br>内容:cl hellowin.c /link user32.lib gdi32.lib winmm.lib<BR>
<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 + -