System sound PlaySnd in VB.NET

  • Thread starter Thread starter Nick
  • Start date Start date
N

Nick

Hi there,

Im trying to use the PlaySnd API to play a system sound, such as
"Asterisk" or "Question" within the windows section. Anyone got any ideas
on how this is done? I've tried using the SND_APPLICATION and SND_ALIAS
flags but I'm thinking that my name isnt correct in the first place, should
I be using "Windows\Asterisk"? Thanks in advance.
 
Okay well I've found some of the keys I need to use but not yet
unfortunately, for anyone elses reference you can achieve it via the
following,

Private Const SND_PURGE As Integer = &H40
Private Const SND_APPLICATION As Integer = &H80
Private Const SND_ASYNC As Integer = &H1

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

PlaySound(<name>, Nothing, SND_PURGE Or SND_ASYNC Or SND_APPLICATION)

<name> - SystemAsterisk
<name> - SystemHand
<name> - SystemExclamation
<name> - SystemQuestion

..... Still looking for more..

Nick.
 
Nick said:
Im trying to use the PlaySnd API to play a system sound, such as
"Asterisk" or "Question" within the windows section. Anyone got any ideas
on how this is done? I've tried using the SND_APPLICATION and SND_ALIAS
flags but I'm thinking that my name isnt correct in the first place,
should I be using "Windows\Asterisk"? Thanks in advance.

I am curious why you do not use 'MessageBeep':

Implementing a message box with standard behavior
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=custommsgbox&lang=en>
 
There is an example of using SndPlaySnd in Windows Forms Tips and Tricks.
The constants for the operations are also included.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
Hi Herfried,

Cheers! I didn't actually know this existed! Thanks for your help.

Nick.
 
Hi Bob,

Cheers for the info, Herfried just pointed out an API I didn't know
existed, which is most helpful. Cheers again.

Nick.

Bob Powell said:
There is an example of using SndPlaySnd in Windows Forms Tips and Tricks.
The constants for the operations are also included.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 

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