OT,
I wrote this class (below), to handle sound. Maybe you can modify it for
your own needs.
I made this because I had to make my own messsage box and didn't won't the
beep sound. You can call
PlaySoundFile passing a wavefile's path and it will play.
or you can call one of the system sounds like this
PlaySYSTEM_ASTERISK (this plays whatever is associated with Asterisk in the
windows sounds in control panel.)
There is a way to add your own sounds to the control panel as you spoke of.
****MSDN****
Registering Sound Events
Your application can register specific events to which the user can assign
sound files. When those events are triggered, the assigned sound file is
played. To register a sound event, create a key under the HKEY_CURRENT_USER
key, as follows:
HKEY_CURRENT_USER
AppEvents
Event Labels
EventName = Event Name
Set the value for EventName to a name that users can read. This is what will
appear in Control Panel.
Registering a sound event makes it available in Control Panel so that users
can assign a sound file to it. Your application must provide the code to
trigger that event when appropriate.
Defining as many sound events as possible for your application can be
especially helpful for users who need additional feedback - for example,
users with visual and some types of cognitive impairments. This does not
mean that your application must generate sounds for all events. You can
simply not assign sounds to an event by default. This way, users who want
additional feedback can use Control Panel to add appropriate sounds.
Always specify sounds to be played by using registry entries. Avoid
specifying sounds by file name or resource, because these cannot be
customized through Control Panel, and because accessibility aids cannot
determine the meaning of these sounds.
In addition, always trigger standard sound events when carrying out
equivalent actions. For example, if you display the equivalent of a critical
message box, play the SND_ALIAS_SYSTEMEXCLAMATION event sound.
More Information
For more information about system sound events, see the Microsoft Platform
SDK on the MSDN Online Web site at
http://msdn.microsoft.com/ui/guide/sdk.asp.
****end of MSDN****
search for Integrating With the Shell with no filtering....
HTH
Shane
Public Class clsSound
Declare Auto Function PlaySound Lib "winmm.dll" (ByVal name _
As String, ByVal hmod As Integer, ByVal flags As Integer) As Integer
' name specifies the sound file when the SND_FILENAME flag is set.
' hmod specifies an executable file handle.
' hmod must be Nothing if the SND_RESOURCE flag is not set.
' flags specifies which flags are set.
' The PlaySound documentation lists all valid flags.
Public Const SND_SYNC = &H0 ' play synchronously
Public Const SND_ASYNC = &H1 ' play asynchronously
Public Const SND_FILENAME = &H20000 ' name is file name
Public Const SND_RESOURCE = &H40004 ' name is resource name or atom
'private helper method to play system sound synch or async
Private Shared Sub PlaySystemSound(ByVal strSystemSound As String, ByVal
bSynchronous As Boolean)
If bSynchronous Then
PlaySound(strSystemSound, 0, SND_SYNC)
Else
PlaySound(strSystemSound, 0, SND_ASYNC)
End If
End Sub
Public Shared Sub PlaySoundFile(ByVal filename As String)
' Plays a sound from filename.
PlaySound(filename, Nothing, SND_FILENAME Or SND_ASYNC)
End Sub
Public Shared Sub PlaySYSTEM_ASTERISK(Optional ByVal bSynchronous As Boolean
= False)
PlaySystemSound("SystemAsterisk", bSynchronous)
End Sub
Public Shared Sub PlaySYSTEM_EXCLAMATION(Optional ByVal bSynchronous As
Boolean = False)
PlaySystemSound("SystemExclamation", bSynchronous)
End Sub
Public Shared Sub PlaySYSTEM_EXIT(Optional ByVal bSynchronous As Boolean =
False)
PlaySystemSound("SystemExit", bSynchronous)
End Sub
Public Shared Sub PlaySYSTEM_HAND(Optional ByVal bSynchronous As Boolean =
False)
PlaySystemSound("SystemHand", bSynchronous)
End Sub
Public Shared Sub PlaySYSTEM_QUESTION(Optional ByVal bSynchronous As Boolean
= False)
PlaySystemSound("SystemQuestion", bSynchronous)
End Sub
Public Shared Sub PlaySYSTEM_START(Optional ByVal bSynchronous As Boolean =
False)
PlaySystemSound("SystemStart", bSynchronous)
End Sub
End Class
"Ot" <ur***@tds.invalid (use net)> wrote in message
news:eN**************@TK2MSFTNGP09.phx.gbl...
I found information on PlaySound. I implemented it in my program and it
works just dandy. The only little problem is that I have to package the
.wav files and send them along since PlaySound plays a sound file.
One of the options I found in a nice description of PlaySound says that
there are a couple of other choices.
1) The sound can be in the registry and actually controlled/selected by
the end user.
2) The sound can also be embedded in the assembly as long as I can point
to the area containing the sound.
I have no clue as to how to set up the registry for sounds for a
particular application. The wav files have to be installed somewhere on the user's
machine anyway, so this doesn't seem a really great way to go. If it is
fairly simple I might do it anyway.
The best seems to be to embed the wav in the application somehow and play
the in-memory copy. My problem here is I have no idea how to get the
contents of the wav into the application at a referenceable memory
location. And I don't know if there is any conversion required as I bring
it in. There must be some hint in the file as to, for example, how long
the wav is. Or maybe it is self defining with a termination byte
sequence -- maybe an all 0s or all Fs word. No clue.
Any help on the latter two possibilities would be appreciated!
Regards,
Ot