Playing System Sounds/WAV files

D

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
 
A

Armin Zingler

Devlei said:
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_...s_ugroup=microsoft.public.dotnet.languages.vb

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


Armin
 
H

Herfried K. Wagner [MVP]

Devlei said:
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>).
 
D

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top