Follow us on Twitter!
Your life is ending one minute at a time. If you were to die tomorrow, what would you do today?
Wednesday, April 23, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 21
Guests Online: 18
Members Online: 3

Registered Members: 82885
Newest Member: ConiBE
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

C++ playsound()


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 09-07-06 15:49
Ok. I've been attempting to include sound in my project for a certain period of time. Fortuantly, I came across this:

#include <MMSystem.h>

int main()
{
char* WAV = "c:\\ratm-bulletinthehead";
sndPlaySound(WAV, SND_ASYNC);
return 0;
}

However, the compiler states that I have errors like these:

C:\DEV-C_~1\Include\MMSystem.h:896: syntax error before `;'

898 c:\dev-c_~1\include\mmsystem.h
`CALLBACK' was not declared in this scope

Line 898? It say's the same thing about 14 times except with "DWORD" not declared and such. I don't know if this is because a code like this is directly related to VC++ because I am yielding way to many errors. So, I came across this:


#include <windows.h>
#include <mmsystem.h>
#pragma comment(lib, "winmm.lib"Wink

int main() {
PlaySound("ratm-bulletinthehead.wav", NULL, SND_FILENAME | SND_SYNC);
return 0;
}

Well, I got all the necessary headers I would suppose. And it compiles fine, but it can't execute ;S does anyone know a solution e.g change this to that or you just plain can't do it lol.


Author

RE: C++ playsound()


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 09-07-06 16:03
Well, this works..

Code

#include <windows.h>
#include <mmsystem.h>
#pragma comment(lib, "winmm.lib")

int main(int argc, char *argv[])
{
   PlaySound("C:\\test.wav", NULL, SND_FILENAME | SND_SYNC);
   return 0;
}





so I'm going to guess that you forgot to specify the full path to your .wav file. ;)

Edited by on 09-07-06 16:04
Author

RE: C++ playsound()


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 09-07-06 16:07
Lol, I even renamed my ratm song to test.wav, copied and paste and in the compiler logs I see this:

c:\dev-c++\untitled1.o(.text+0x27):untitled1.cpp: undefined reference to `PlaySoundA@12'

>: ( what compiler did you use?
Author

RE: C++ playsound()


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 09-07-06 16:13
I'm using Visual Studio 2003 .NET, but try the following..


Project -> Project Options -> Paramters

In the text box labeled 'Linker', add the flag:
Code:

-lwinmm
Author

RE: C++ playsound()


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 09-07-06 16:18
Woot...worked thanks a lot man Smile
Author

RE: C++ playsound()


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 09-07-06 16:20
No problem, but you should check out msdn.com and search for their free copy of MSVC Express 2005 it will save you a lot of headaches and I think it's a lot more organized than Dev-C++, but to each his own.
Author

RE: C++ playsound()


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 09-07-06 16:21
Yeah I think I will, thanks again man I was searching forever lol.