How can I play "standard system sounds" in C# ?

  • Thread starter Thread starter Steph.
  • Start date Start date
S

Steph.

Hi !

How can I play "standard system sounds" in C# ?

( "standard system sounds" = The kind of sound you hear when you use MessageBox.Show() )

Thanks !

steph.
 
Assuming you are using .NET 2.0 you can use SystemSounds class:

System.Media.SystemSounds.Asterisk.Play();

SystemSounds class also has other members Beep, Hand and Question.
 
yogeshprabhu said:
Assuming you are using .NET 2.0 you can use SystemSounds class:

System.Media.SystemSounds.Asterisk.Play();

SystemSounds class also has other members Beep, Hand and Question.
 
Steph,

As VJ pointed out for .NET 1.x besides simple beeps that can be made using Microsoft.VisualBasic.dll (some people have problems referencing this dll in C# application, but it is still a managed assembly installed along with the framework) there is no way playing sounds wihtout resorting to native API and PInvoke.

If you are using .NET1.x and decide to go for native API take a look at the MessageBeep method.


--
HTH
Stoitcho Goutsev (100)
if you are in Framework 1.1... you with interop... chk the link out...

http://pinvoke.net/search.aspx?search=sound&namespace=[All]

VJ
Hi !

How can I play "standard system sounds" in C# ?

( "standard system sounds" = The kind of sound you hear when you use MessageBox.Show() )

Thanks !

steph.
 
This, http://www.codeproject.com/cs/media/PlaySounds1.asp, shows you exactly what you want to know. It is .NET 1.x code, but it is insanely easy in .NET 2.0 to play system sounds. They took out all the Interop fun! ;(

Hi !

How can I play "standard system sounds" in C# ?

( "standard system sounds" = The kind of sound you hear when you use MessageBox.Show() )

Thanks !

steph.
 
Interop fun... uhmmm that is an interesting phase :-)

VJ
"FusionGuy" <sbearusa32 at &emSen& dot com> wrote in message This, http://www.codeproject.com/cs/media/PlaySounds1.asp, shows you exactly what you want to know. It is .NET 1.x code, but it is insanely easy in .NET 2.0 to play system sounds. They took out all the Interop fun! ;(

Hi !

How can I play "standard system sounds" in C# ?

( "standard system sounds" = The kind of sound you hear when you use MessageBox.Show() )

Thanks !

steph.
 

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

Back
Top