Results 1 to 14 of 14

Thread: API - PlaySound

  1. #1

    Thread Starter
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298

    Question

    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??

    Visual Basic 6.0 Enterprise
    Visual C++ 6.0 Professional

    Wak

  2. #2
    Lively Member rekcus's Avatar
    Join Date
    Jan 1999
    Location
    Kuala Lumpur
    Posts
    122
    Did you do something like this?
    Code:
    PlaySound (TEXT("\\windows\\mi.wav"), NULL, SND_ASYNC | SND_NODEFAULT);
    Also, check that your system's got all the necessary multimedia drivers.
    penyou!

    "The code bytes.."

  3. #3
    Guest
    Try including this file

    Code:
    Mmsystem.h

  4. #4
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    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.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  5. #5
    Guest
    Winmm.lib

  6. #6
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Yes! Winmm.lib.So for Wak:
    Goto Project->Settings->link tab->and under library modules add Winmm.lib. Then add this code.
    Code:
    #include <mmsystem.h>
    ...
    PlaySound("c:\\windows\\media\\chimes.wav",NULL, SND_ASYNC  | SND_FILENAME );
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  7. #7

    Thread Starter
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298

    Question ...Still Doesn't Work...

    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

    Visual Basic 6.0 Enterprise
    Visual C++ 6.0 Professional

    Wak

  8. #8
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Include the windows.h
    Code:
    #include <windows.h>
    #include <mmsystem.h>
    ...
    PlaySound("c:\\windows\\media\\chimes.wav",NULL, SND_ASYNC  | SND_FILENAME );
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  9. #9

    Thread Starter
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298

    :confused: I still can't get it :confused:

    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.

    Visual Basic 6.0 Enterprise
    Visual C++ 6.0 Professional

    Wak

  10. #10
    Lively Member rekcus's Avatar
    Join Date
    Jan 1999
    Location
    Kuala Lumpur
    Posts
    122
    My friend, tell us all it you included this ->
    Code:
    #include <mmsystem.h>

    penyou!

    "The code bytes.."

  11. #11
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    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.
    Code:
    //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 );
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  12. #12

    Thread Starter
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298

    By George, I think I got it....

    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.

    Last edited by Wak; Jan 20th, 2001 at 11:06 PM.
    Visual Basic 6.0 Enterprise
    Visual C++ 6.0 Professional

    Wak

  13. #13
    Guest
    I use the Platform SDK.... it's a great tool.. you should get it..

    I think it's available from:

    http://msdn.microsoft.com

  14. #14
    Hyperactive Member jovton's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    266

    Smile

    Or better yet, get Visual Studio 6.0 Enterprise Edition.
    (I think 7 is on the way...)
    jovton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width