Calling Default Windows Sound Events

ssteinke

for what it's worth
Local time
Today, 17:31
Joined
Aug 2, 2003
Messages
195
I implemented ghudson's suggestion here for creating a formatted MsgBox.

I noticed that the default windows sounds that normally play with the standard VBA MsgBox function don't play.

Is there any way to manually call the 'Default' Windows Sound Events. I've searched the forum and only see ways of playing specific wav files like this. But is their a way to call the 'Default Exclamation' for example, which is determined by the windows user.

Thanks for your time,

Scott
 
Yes, when I get to work I'll have time to reply.

Edit:
Well I'm here at work, but I cannot get into the registry editor to see where the system sounds are stored, I believe it's
HKEY_CURRENT_USER\AppEvents\Schemes\Apps... I'm really not sure, but the information should be stored in the registry

use the sndPlaySound API to call the sound
 
Last edited:
Thanks for pointing me in the right direction modest, this is a quick function i wrote that seems to work well for my purposes

Code:
Declare Function apiPlaySound Lib "Winmm.dll" Alias "sndPlaySoundA" _
    (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Function PlaySoundEvent(ByVal SndEvent As String) As Long
    PlaySoundEvent = apiPlaySound(SndEvent, 1)
End Function


Code:
Sub Test()
    PlaySoundEvent ("[COLOR=DarkRed]EventNameGoesHere[/COLOR]")
End Sub

Some common event names I found in the registry include:
Close
MailBeep
Maximize
MenuCommand
MenuPopup
Minimize
Open
RestoreDown
RestoreUp
SystemAsterisk
SystemExclamation
SystemExit
SystemQuestion
SystemStart​

Thanks again for your help, much appreciated

Scott
 
Last edited:

Users who are viewing this thread

Back
Top Bottom