PlaySound problems on XP

PlaySound problems on XP

Post by M. Kool » Fri, 26 Nov 2004 02:56:01


Hi,

We're having some trouble here to get a sound played. We have the
following code:

#include <mmsystem.h>
void PlayJobNotificationSound( int32 inResourceID)
{
if( !::PlaySound( MAKEINTRESOURCE( inResourceID), ::GetModuleHandle(
NULL), SND_RESOURCE | SND_NODEFAULT))
{
::MessageBeep( MB_ICONEXCLAMATION);
}
}

I have downloaded a sample project which employs the same method and it
works fine there. If we try it in our application, it just doesn't work;
it always returns FALSE. What's up with that??

Thanks!

--
Maarten Kools
___________________________________________
Van Gennep - Media Automation Consulting bv
Burg. Stramanweg 105
1101 AA Amsterdam
The Netherlands

Phone: +31-20-697 6029
Fax: +31-20-697 2249
E-mail: XXXX@XXXXX.COM
WWW: http://www.yqcomputer.com/
WWW: http://www.yqcomputer.com/
___________________________________________
 
 
 

PlaySound problems on XP

Post by Chris P. [ » Fri, 26 Nov 2004 07:20:26


Make sure that the Module handle you are getting is valid. Aside from that
if you are running as an application it should work.

 
 
 

PlaySound problems on XP

Post by M. Kool » Fri, 26 Nov 2004 20:15:02


I have also tried using AfxGetInstanceHandle, not sure if that's exactly
the same though.

Oh! I also checked GetLastError, but that only returns 0

--
Maarten Kools
___________________________________________
Van Gennep - Media Automation Consulting bv
Burg. Stramanweg 105
1101 AA Amsterdam
The Netherlands

Phone: +31-20-697 6029
Fax: +31-20-697 2249
E-mail: XXXX@XXXXX.COM
WWW: http://www.yqcomputer.com/
WWW: http://www.yqcomputer.com/
___________________________________________
 
 
 

PlaySound problems on XP

Post by M. Kool » Sat, 27 Nov 2004 20:26:14


Eventually found the error. Apparently the wav file wasn't properly
created, it should've been in a RIFF format and it wasn't for some reason.

--
Maarten Kools
___________________________________________
Van Gennep - Media Automation Consulting bv
Burg. Stramanweg 105
1101 AA Amsterdam
The Netherlands

Phone: +31-20-697 6029
Fax: +31-20-697 2249
E-mail: XXXX@XXXXX.COM
WWW: http://www.yqcomputer.com/
WWW: http://www.yqcomputer.com/
___________________________________________
 
 
 

PlaySound problems on XP

Post by Chris P. [ » Sat, 27 Nov 2004 23:40:08


Okay, good to know. Would of been nice if it returned an error wouldn't
it? :)

-Chris