PDA

Click to See Complete Forum and Search --> : API - PlaySound


Wak
Jan 17th, 2001, 01:42 AM
Thanx all for reading and replying to my message in advance.

I just want to make an App for Windows, that uses PlaySound
API function, to play a sound. I'm getting it right, but it just gives me an error saying previous declaration not found, or something along those lines. What am I doing wrong??? Or how do I define it before I call it??

:eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek: :eek::eek::eek::eek:

rekcus
Jan 17th, 2001, 04:57 AM
Did you do something like this?

PlaySound (TEXT("\\windows\\mi.wav"), NULL, SND_ASYNC | SND_NODEFAULT);

Also, check that your system's got all the necessary multimedia drivers.

Jan 17th, 2001, 05:41 AM
Try including this file


Mmsystem.h

Vlatko
Jan 17th, 2001, 11:40 AM
Yes it should work with mmsystem.h but unresolved external shi* error occurs. I had this error when i used the wininet.h but the problem was solved by adding the wininet.lib in the project settings. There may be a *.lib for mmsystem but it is not called mmsystem.lib.

Jan 17th, 2001, 01:38 PM
Winmm.lib

Vlatko
Jan 17th, 2001, 02:07 PM
Yes! Winmm.lib.So for Wak:
Goto Project->Settings->link tab->and under library modules add Winmm.lib. Then add this code.

#include <mmsystem.h>
...
PlaySound("c:\\windows\\media\\chimes.wav",NULL, SND_ASYNC | SND_FILENAME );

Wak
Jan 17th, 2001, 11:37 PM
Sorry to keep bothering you all, but I have added the library winmm.lib to the right spot, then used the include statement at the top, and still, I can't get it to work. It keeps saying the same thing, "error C2065: 'PlaySound' : undeclared identifier".

One more thing, I noticed that Vlatko and denniswrenn spelt mmsystem differently, one with the capital M one without out, does this matter??

Once again, thanx for the help in advance

:):):):):):):):):):):):):):):):):):):):):):):):):):):):):):)

Vlatko
Jan 18th, 2001, 04:43 AM
Include the windows.h

#include <windows.h>
#include <mmsystem.h>
...
PlaySound("c:\\windows\\media\\chimes.wav",NULL, SND_ASYNC | SND_FILENAME );

Wak
Jan 18th, 2001, 08:17 PM
I'm still not sure, but I have done exactly every thing the way as said. But now I am getting to more errors. They are:

error C2065: 'PlaySound' : undeclared identifier
error C2065: 'SND_ASYNC' : undeclared identifier
error C2065: 'SND_FILENAME' : undeclared identifier

I know the last 2 errors is because I haven't declared the variables, which is really no hassel, cause I can just get teh values and declare them. But the first error, I am still stuck on, and I really need help. Anyone, please help, this is driving me crazy.

:confused::confused::confused::confused::confused::confused::confused::confused::confused::confused: :confused::confused::confused::confused::confused::confused::confused::confused::confused::confused: :confused::confused::confused::confused:

rekcus
Jan 18th, 2001, 08:27 PM
My friend, tell us all it you included this ->
#include <mmsystem.h>

Vlatko
Jan 19th, 2001, 05:25 AM
You dont have to declare the constants in C++ like in VB. 'SND_FILENAME' and 'SND_ASYNC' are constants not variables by the way. Just include the files and they shouldn't be undeclared then.

//put this at the beggining of the cpp file
#include <windows.h>
#include <mmsystem.h>

//then put this on some event (ex.button click)
PlaySound("c:\\windows\\media\\chimes.wav",NULL, SND_ASYNC | SND_FILENAME );

Wak
Jan 20th, 2001, 10:02 PM
Thanx all for the help. I got the sound thing working, but now of couse, I can't be satisfied, and I have to ask another question:

How do you know which files to include??

I know you have to include winmm.lib cause the function resides within winmm.dll

But how come you have to include <mmsystem.h>

I'm guessing that there is a special include file for each windows API dll. If so which include files do you need to include for each dll's. Maybe there is a site or something, that could help me.

Thanx for the help once again.

:cool::cool::cool::cool::cool::cool::cool::cool::cool::cool::cool::cool::cool::cool::cool::cool:

Jan 21st, 2001, 08:33 AM
I use the Platform SDK.... it's a great tool.. you should get it..

I think it's available from:

http://msdn.microsoft.com

jovton
Jan 24th, 2001, 01:44 PM
Or better yet, get Visual Studio 6.0 Enterprise Edition.
(I think 7 is on the way...)