播放WAV

vb6使用方法

'声明

Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
 Const SND_ASYNC = &H1   '异步播放
 Const SND_SYNC = &H0   '同步播放   (缺省)
Private opFlag As Boolean

'调用

Dim SoundFile As String, Result As Long
SoundFile = "goodsound.wav"
Result = sndPlaySound(SoundFile, SND_ASYNC)

'注:

 '       将winmm.dll和goodsound.wav拷贝到程序目录下

 

vb.net使用方法

 

'声明 

Private Declare Auto Function PlaySound Lib "winmm.dll" (ByVal lpszSoundName As String, ByVal hModule As Integer, ByVal dwFlags As Integer) As Integer
    Const SND_FILENAME As Integer = &H20000

    Const SND_ALIAS As Integer = &H10000

    Const SND_SYNC As Integer = &H0

'调用
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim SoundFile As String
        SoundFile = "goodsound.wav"
        PlaySound(SoundFile, 0, SND_FILENAME)
    End Sub

'注:

      '将winmm.dll和goodsound.wav拷贝到程序目录下

还是有点区别的

posted @ 2009-05-19 16:21  TNTZWC  阅读(298)  评论(0编辑  收藏  举报