-
PlaySound error
I am trying to make a call to playsound:
Code:
PlaySound (TEXT ("hellowin.wav"), NULL, SND_FILENAME | SND_ASYNC) ;
But I am getting these 2 errors:
--------------------Configuration: Windows Programming simp1 - Win32 Debug--------------------
Compiling...
Main.cpp
Linking...
Main.obj : error LNK2001: unresolved external symbol __imp__PlaySoundA@12
Debug/Windows Programming simp1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Windows Programming simp1.exe - 2 error(s), 0 warning(s)
Does that mean that I can't make a call to that particular function with xp?
EDIT:
This ebook seems old, instead of using PeekMessage it uses GetMessage and isntead of TextOut() it uses DrawText...Where can I find a more up-to-date e-book?
-
It means it cannot find the implementation of the function PlaySound. You probably are not linking to the necessary library. Try linking to winmm.lib and try again.
-
Shadow, how is GetMessage old?
-
Well maybe it isn't 'old' but I thought there were newer functions for it, for example peekmessage (I saw that in my game programming book). I wasn't really telling you guys it was old, I was more or less asking if it was old cuz i don't yet know a damn thing about the winapi.
EDIT:
I linked the winmm.lib and it made a beep! sweet!
What directory does it search for by default when it goes to play a sound? I don't think that beep was the correct sound cuz it was just my case speaker, but I made it player another wav..why do you have to have double slashes when specifying a directory like :
C:\\Program Files\\KaZaA\\My Shared Folder\\quake.wav (that's what I put in there instead)
-
DrawText is not superseded by TextOut...they just work differently....either is fine....
PeekMessage should not be used for standard GUI apps......GetMessage is fine. PeekMessage should only be used for performance app like games, as they cant afford to wait for the next message
-
You have to have double slashes because the \ just happens to be a special character which says that the next character is to be taken litterally. So if you want to use a reserved character like * but you want to use it as a * and not as wildcard you use \*. Because of this the \ itself is a special character and itself must be proceeded with a \ if you want to use it as a \ and not a as prefix of a special character.
printf("Hi there.\n");
Hi there.
printf("Hi there.\\n");
Hi there.\n
printf("Hi there.\\\n");
Hi there.\
Hope that helps explain it.