all groups > dotnet windows forms > january 2008 >
You're in the

dotnet windows forms

group:

How to play a Windows sound?


How to play a Windows sound? nvx
1/31/2008 2:07:40 PM
dotnet windows forms:
Hello,
I would like to play at a certain moment the exact sound that Windows
play when an information message box is shown (the one with blue "i"
in the bubble). I know I could find the .wav file and play it somehow,
but I'd like to play the sound that is assigned to the info message
box in the Windows settings. Is there a way to do this?

Thanks for any hints.

Best regards,
Re: How to play a Windows sound? Jeff Gaines
1/31/2008 2:45:01 PM
On 31/01/2008 in message
<9c213ad5-ece6-4168-8692-3e21cb8a9313@e25g2000prg.googlegroups.com> nvx
[quoted text, click to view]

I think you will need to use the Windows API and call MessageBeep:

// MessageBeep
[DllImport("user32.dll")]
public static extern int MessageBeep(int wType);

You can set wType to:
-1 - Simple beep
MB_ICONASTERISK 0x00000040L SystemAsterisk
MB_ICONEXCLAMATION 0x00000030L SystemExclamation
MB_ICONHAND 0x00000010L SystemHand
MB_ICONQUESTION 0x00000020L SystemQuestion
MB_OK 0x00000000L SystemDefault

--
Re: How to play a Windows sound? Gregg Walker
1/31/2008 3:15:34 PM
With .Net Framework 2.0 or later...

using system.media;

PlaySystemSound(SystemSounds.Asterisk);
--
Gregg Walker

Re: How to play a Windows sound? nvx
2/1/2008 1:37:18 AM
Jeff, Gregg, Herfried,
thank you all very much for you replies. It works just the way I need.

Best regards,
nvx


On 1 =DAn, 02:01, "Herfried K. Wagner [MVP]" <hirf-spam-me-h...@gmx.at>
[quoted text, click to view]
Re: How to play a Windows sound? Herfried K. Wagner [MVP]
2/1/2008 2:01:25 AM
"Gregg Walker" <xyzzy@newsgroup.nospam> schrieb:
[quoted text, click to view]

=> 'SystemSound.Asterisk.Play()'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
Re: How to play a Windows sound? Gregg Walker
2/1/2008 10:27:51 AM
[quoted text, click to view]

Herfried -- Minor clarification that should be...

SystemSounds.Asterisk.Play()

Thanks for pointing that out. I did not know the SystemSounds supported a
Play method.

--
Gregg Walker

Re: How to play a Windows sound? Gregg Walker
2/1/2008 10:42:50 AM
Herfried -- Boy I really boned that up.

PlaySystemSound(SystemSounds.Asterisk);

PlaySystemSound is a method I added to one of my class libraries for playing
various sounds.

Thanks again for your clarification.
--
Gregg Walker

AddThis Social Bookmark Button