Results 1 to 4 of 4

Thread: Playing a sound file

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    Playing a sound file

    I tried this code when the window loads to play a sound file which placed in the directory where my source files are:

    Code:
    case WM_CREATE:
    
    PlaySound("hellowin.wav" ,NULL,SND_FILENAME | SND_ASYNC);
    		return 0;
    It gives me this error:

    hellowin.obj : error LNK2001: unresolved external symbol __imp__PlaySoundA@12
    Baaaaaaaaah

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Try adding winmm.lib to the list of libraries (under Project Settings)
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    THanks a lot

    That works now!

    But Why did I need that library?
    Baaaaaaaaah

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    LOL @ the sig

    Because the library doesn't contain any code, only the definitions for the functions. You'll notice that each library roughtly corresponds to each DLL. Since PlaySound is in winmm.dll (or something similar), it's logical for it to be in winmm.lib. Likewise, Sleep (kernel32.dll) is in kernel32.lib
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

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