📄 subject_29864.htm
字号:
<p>
序号:29864 发表者:skygreen 发表日期:2003-02-14 14:40:29
<br>主题:大侠,请帮忙运行一下此程序,如何消除此错误。
<br>内容:LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main<BR>Debug/simpwin.exe : fatal error LNK1120: 1 unresolved externals<BR>Error executing link.exe.<BR><BR>simpwin.exe - 2 error(s), 0 warning(s)<BR><BR><BR><BR>#include<windows.h><BR>#include<string.h><BR><BR>LRESULT CALLBACK MainWndProc(HWND,UINT,WPARAM,LPARAM);<BR><BR>BOOL InitApplication(HINSTANCE);<BR>BOOL InitInstance(HINSTANCE,int);<BR><BR>char *hello="窗口外的世界很精彩,窗口内的天地也很奇妙";<BR><BR>HINSTANCE hInst;<BR>HWND hWndMain;<BR><BR>int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,<BR> LPSTR lpCmdLine,int nCmdShow)<BR>{<BR> MSG msg;<BR><BR> if(!InitApplication(hInstance))<BR> return FALSE;<BR> if(!InitInstance(hInstance,nCmdShow))<BR> return FALSE;<BR> while(GetMessage(&msg,NULL,0,0))<BR> {<BR> TranslateMessage(&msg);<BR> DispatchMessage(&msg);<BR> }<BR> return msg.wParam;<BR>}<BR><BR>BOOL InitApplication(HINSTANCE hInstance)<BR>{<BR> WNDCLASS wcSimpwin;<BR><BR> wcSimpwin.style=0;<BR> wcSimpwin.lpfnWndProc=(WNDPROC)MainWndProc;<BR> wcSimpwin.cbClsExtra=0;<BR> wcSimpwin.cbWndExtra=0;<BR> wcSimpwin.hInstance=hInstance;<BR> wcSimpwin.hIcon=LoadIcon(NULL,IDI_APPLICATION);<BR> wcSimpwin.hCursor=LoadCursor(NULL,IDC_ARROW);<BR> wcSimpwin.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);<BR> wcSimpwin.lpszMenuName=NULL;<BR> wcSimpwin.lpszClassName="SimpwinWClass";<BR><BR> return RegisterClass(&wcSimpwin);<BR>}<BR><BR><BR>BOOL InitInstance(HINSTANCE hInstance,int nCmdShow)<BR>{<BR> hInst=hInstance;<BR><BR> hWndMain=CreateWindow("SimpwinWClass","MY WINDOW",WS_OVERLAPPEDWINDOW,<BR> CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,<BR> NULL,NULL,hInstance,NULL);<BR><BR> if(!hWndMain)return FALSE;<BR><BR> ShowWindow(hWndMain,nCmdShow);<BR> UpdateWindow(hWndMain);<BR> return TRUE;<BR>}<BR><BR>LRESULT CALLBACK MainWndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)<BR>{<BR> HDC hdc;<BR> PAINTSTRUCT ps;<BR> switch(message)<BR> {<BR> case WM_PAINT:<BR> hdc=BeginPaint(hWnd,&ps);<BR> TextOut(hdc,20,10,hello,lstrlen(hello));<BR> EndPaint(hWnd,&ps);<BR> break;<BR> case WM_DESTROY:<BR> PostQuitMessage(0);<BR> break;<BR> default:<BR> return DefWindowProc(hWnd,message,wParam,lParam);<BR> }<BR> return 0;<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>回复者:upstream 回复日期:2003-02-14 15:08:28
<br>内容:程序本身没有问题,估计是你的工程类型有问题。<BR>象你这样sdk类型的程序,应该选择Win32 Application工程类型,然后把文件插入。<BR><BR>我已经编译链接通过,运行正常。请看附件抓图。<BR><BR><BR><BR>2003-2-14 15:16:49
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -