读书人

帮忙看下错在那里?该如何解决

发布时间: 2012-02-27 10:00:22 作者: rapoo

帮忙看下错在那里?
[code=C/C++][/code]/*------------------------------
HELLOWIN.C----Displays "Hllo,Windows 98!"! in client area(c)
Charles Petzold,1998
----------------------------------*/
#include<windows.h>
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrecInstance,PSTR szCmdLine,int iCmdShow)
{
static TCHAR szAppName[]=TEXT("HelloWin");
HWNDhwnd;
MSGmsg;
WNDCLASSwndclass;
wndclass.style =CS_HREDRAW|CS_VREDRAW;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoasIcon(NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=szAppName;
if(!RegisterClass(&wndclass))
{
MessageBox(NULL,TEXT("This program requires Windows NT!"),szAppName,MB_ICONERROR);
return 0;
}
hwnd=CreateWindow(szAppName,
TEXT("The hello Program"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd,iCmdShow);
UpdateWindow(hwnd);

while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
HDChdc;
PAINTSTRUCTps;
RECTrect;

switch(message)
{
case WM_CREATE:
PlaySound(TEXT("hellowin.wav"),NULL,SND_FILENAME|SND_ASYNC);
return 0;

case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);

GetClientRect(hwnd,&rect);

DrawText(hdc,TEXT("Hell,Windows 98!"),-1,&rect,
DT_SINGLELINE|DT_CENTER|DT_VCENTER);
EndPaint(hwnd,&ps);
return 0;

case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd,message,wParam,lParam);
}
编译时无错,但在形成EXE时就会提示:
--------------------Configuration: chuangkou - Win32 Debug--------------------
Linking...
chuangkou.obj : error LNK2001: unresolved external symbol _LoasIcon
chuangkou.obj : error LNK2001: unresolved external symbol __imp__PlaySoundA@12
Debug/chuangkou.exe : fatal error LNK1120: 2 unresolved externals
执行 link.exe 时出错.

chuangkou.exe - 1 error(s), 0 warning(s)
我在书上抄的 ,是窗口的源程序,
用的是VC++6.0;
在书上看小写l和大写i一摸一样,根本分不开!
我是哪里错了啊 !



[解决办法]
LoasIcon改成LoadIcon

读书人网 >C语言

热点推荐