Re: system sounds
- From: "MikeD" <nobody@xxxxxxxxxxx>
- Date: Fri, 5 Jan 2007 21:15:35 -0500
"Global" <a@xxxxx> wrote in message news:6oCnh.19721$U12.16734@xxxxxxxxxxxxxxxxxxxxxxxxx
Hi, is there a WINAPI function that can play system sounds? I need to notify user when new mail arrives.
The PlaySound (or sndPlaySound, but PlaySound is preferred) Win32 API function can play system sounds. Open up Sounds and Audio Devices from Control Panel. Click the Sounds tab. The system sounds are those that are listed under "Windows", and, lucky for you, "New Mail Notification" is one of them. However, that's the sound's description, not it's "name". To get the name, you have to dig into the Registry.
HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default
The subkeys you see listed are the names (or identifier or ID, if you'd rather think of it that way) of the system sound events. To play any of them, use code such as this:
Option Explicit
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Const SND_ASYNC = &H1 ' play asynchronously
Private Const SND_ALIAS = &H10000 ' name is a WIN.INI [sounds] entry
Private Sub Form_Click()
PlaySound "mailbeep", 0&, SND_ALIAS Or SND_ASYNC
End Sub
You can play any of these system sounds in this same manner. For example, to play Windows' startup sound:
PlaySound "systemstart", 0&, SND_ALIAS Or SND_ASYNC
--
Mike
Microsoft MVP Visual Basic
.
- References:
- system sounds
- From: Global
- system sounds
- Prev by Date: Re: system sounds
- Next by Date: Re: CIM Repository
- Previous by thread: Re: system sounds
- Next by thread: Re: system sounds
- Index(es):
Relevant Pages
|
Loading