PlaySound error

This is a discussion on PlaySound error within the Windows Programming forums, part of the Platform Specific Boards category; I am trying to make a call to playsound: Code: PlaySound (TEXT ("hellowin.wav"), NULL, SND_FILENAME | SND_ASYNC) ; But I ...

  1. #1
    Shadow12345
    Guest

    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?
    Last edited by Shadow12345; 09-28-2002 at 03:04 PM.

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    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.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  3. #3
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    Shadow, how is GetMessage old?

  4. #4
    Shadow12345
    Guest
    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)
    Last edited by Shadow12345; 09-28-2002 at 05:06 PM.

  5. #5
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    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

  6. #6
    Registered User
    Join Date
    Aug 2002
    Posts
    170
    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.
    Best Regards,

    Bonkey

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 12:10 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21