Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use "sndPlaySound" in Win32 App. 1

Status
Not open for further replies.

petitbourgeois

Programmer
Jan 10, 2000
2
CA
Good morning guys:<br>
<br>
I am building a small app, an alarm clock. It is a dialog-based program, generated through the MFC AppWizard in VC++ 6.0. Ithen use a timer to verify when it is time to sound the alarm. I wanted to use the sndPlaySound API instruction, but can't seem to get it to work. I tried its equivalent PlaySound, and it does the same. <br>
Here is my syntax:<br>
<br>
sndPlaySound(&quot;tada.wav&quot;, SND_ASYNC);<br>
<br>
The error message I keep getting is as follows:<br>
<br>
Chap4Dlg.obj : error LNK2001: unresolved external symbol __imp__sndPlaySoundA@8<br>
Debug/Chap4.exe : fatal error LNK1120: 1 unresolved externals<br>
Error executing link.exe.<br>
<br>
Chap4.exe - 2 error(s), 0 warning(s)<br>
<br>
Do I need to give the compiler any specific directive in order to use Win API instructions ? Or is there an API LIB I should link the program with ?<br>
<br>
Thanks a lot for your help guys !<br>
<br>
Simon <p>Zoopsie<br><a href=mailto:petit_bourgeois@videotron.ca>petit_bourgeois@videotron.ca</a><br><a href= > </a><br>I understand the process of the linked lists. What power !
 
Two things that I would try. <br>
1 - Try adding MMSYSTEM.DLL to your project -- that's<br>
where sndPlaySound comes from<br>
2 - Use the C++ API PlaySound instead -- it probably <br>
ends up calling sndPlaySound anyway and you won't have<br>
the linker issue that you're seeing because PlaySound<br>
comes right out of the C++ runtime libraries.<br>
<br>
Here is the function prototype for PlaySound:<br>
<br>
BOOL PlaySound(LPCSTR pszSound, <br>
HMODULE hmod, <br>
DWORD fdwSound);<br>
<br>
Here's an example:<br>
BOOL ret = PlaySound(&quot;tada.wav&quot;,NULL,SND_FILENAME);<br>
<br>
Good Luck! <p>Pat Gleason<br><a href=mailto:gleason@megsinet.net>gleason@megsinet.net</a><br><a href= > </a><br>
 
Thanks Pat !<br>
<br>
I found that I hadn't read it all, or correctly. I was supposed to include the winmm.lib. In the future I will know that there is a portion at the end of the topic on-line help mentionning what is required for it to work...<br>
<br>
But I still went as you said, and used PlaySound(). Less pain, and it worked well. Thanks a lot for your time and help.<br>
<br>
Simon <p>Zoopsie<br><a href=mailto:petit_bourgeois@videotron.ca>petit_bourgeois@videotron.ca</a><br><a href= > </a><br>I understand the process of the linked lists. What power !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top