Home All Groups Group Topic Archive Search About

Playing System Sounds/WAV files

Author
15 Mar 2006 10:30 AM
Devlei
Can someone please point me in the right direction as to how to play
system sounds and/or WAV files from a VS.Net 2003 application.

I can find plenty of info about how easy it is with VS2005, but from
VS.Net 2003 I can only find the Windows Multimedia article about the
Statement:  PlaySound("MouseClick", NULL, SND_SYNC). But how do I use
this statement?

With thanks
Dave

Author
15 Mar 2006 11:20 AM
Armin Zingler
"Devlei" <dev***@eastcape.net> schrieb
> Can someone please point me in the right direction as to how to play
> system sounds and/or WAV files from a VS.Net 2003 application.
>
> I can find plenty of info about how easy it is with VS2005, but from
> VS.Net 2003 I can only find the Windows Multimedia article about the
> Statement:  PlaySound("MouseClick", NULL, SND_SYNC). But how do I
> use this statement?


http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_playsound.asp


Declaration:

Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _
   (ByVal lpszName As String, ByVal hModule As IntPtr, _
   ByVal dwFlags As Integer) As Boolean

You can overload the declaration depending on what you are passing to the
function.

See also:
http://groups.google.com/groups?as_q=PlaySound&num=10&scoring=d&as_ugroup=microsoft.public.dotnet.languages.vb

includes this link posted by Herfried:
http://dotnet.mvps.org/dotnet/code/misc/#PlaySound


Armin
Author
15 Mar 2006 11:58 AM
Herfried K. Wagner [MVP]
"Devlei" <dev***@eastcape.net> schrieb:
> Can someone please point me in the right direction as to how to play
> system sounds and/or WAV files from a VS.Net 2003 application.
>
> I can find plenty of info about how easy it is with VS2005, but from
> VS.Net 2003 I can only find the Windows Multimedia article about the
> Statement:  PlaySound("MouseClick", NULL, SND_SYNC). But how do I use
> this statement?

..NET 1.*:

Implementing a message box with standard behavior
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=custommsgbox&lang=en>

<URL:http://dotnet.mvps.org/dotnet/code/misc/#PlaySound>
<URL:http://www.mentalis.org/soft/class.qpx?id=14>
<URL:http://www.mentalis.org/soft/class.qpx?id=1>

..NET 2.0:

Some system sounds can be played using 'System.Media.SystemSounds'
(<URL:http://msdn2.microsoft.com/de-de/library/system.media.systemsounds.aspx>),
wave files can be played using the 'System.Media.SoundPlayer' class
(<URL:http://msdn2.microsoft.com/en-us/library/system.media.soundplayer.aspx>).

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
15 Mar 2006 3:44 PM
Devlei
Thanks for the various links!!!  I copied the sample from your
'Verschiedenes' web page, but get the following error:

An unhandled exception of Type System.NullReferenceException occurred
in PlaySounds.exe
Additional Information: Object Reference not set to an instance of an
object

It occurs at the line :

Dim Length As Integer = CInt(st.Length)

Could you help a newbie further?

With thanks
Dave