播放内嵌的wav文件
' Declarations...
' Play Sound flags
Private Const SND_ASYNC As Integer = &H1
Private Const SND_LOOP As Integer = &H8
Private Const SND_MEMORY As Integer = &H4
Private Const SND_NODEFAULT As Integer = &H2
Private Const SND_NOSTOP As Integer = &H10
Private Const SND_SYNC As Integer = &H0
' Play Sound declaration
Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As Byte(), ByVal uFlags As Integer) As Integer
' Calling Code...
' Name of the resource to extract
Dim rName As String = "cameraclick.wav"
' Obtain the assembly name and replace '-' with an underscore
Dim rSchema As String = Replace(Reflection.Assembly.GetExecutingAssembly.GetName.Name, "-", "_") & "." & rName
' Retreive the resource as a stream
Dim rStream As IO.Stream = Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream(rSchema)
' Read the stream into a byte buffer
Dim buffer(rStream.Length) As Byte
rStream.Read(buffer, 0, buffer.Length - 1)
' Play the sound
sndPlaySound(buffer, SND_MEMORY Or SND_ASYNC)