Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As LongPublic Sub PlaySoundFile1(ByVal FileName As String, Optional ByVal Wait As Boolean = False) If Wait Then Call PlaySound(FileName, 0&, SND_FILENAME) Else Call PlaySound(FileName, 0&, SND_ASYNC Or SND_FILENAME) End If End Sub call PlaySoundFile1
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long 这个函数是自己做的吗??我怎么没在msdn里找到??
不错哦!!!讲讲,我出学关于那个winmm.dll是谁的控件??
你知道beep吗?我看过改变beep的声音的办法,但是忘记了,你查查看。
在vb中实现多线程 新建一Module Declare Function CreateThread Lib "kernel32" (lpThreadAttributes As Any, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, lpParameter As Any, ByVal dwCreationFlags As Long, lpThreadID As Long) As Long Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As LongSub main() Load Form1 Form1.Show End Sub Public Sub c1() ....... End SubPublic Sub c2() ...... End Sub新建一窗体Private hthread1 As Long Private hthread2 As Long Private ithread1 As Long Private ithread2 As LongPrivate Sub Command1_Click()ithread1 = CreateThread(ByVal 0&, ByVal 0&, AddressOf c1, ByVal 0&, ByVal 0&, hthread1) --创建线程一 ithread2 = CreateThread(ByVal 0&, ByVal 0&, AddressOf c1, ByVal 0&, ByVal 0&, hthread1) --创建线程二CloseHandle ithread1 --关闭线程一 CloseHandle ithread2 --关闭线程二End Sub
没有这么麻烦吧! 就用一个API函数就可以,要注意一下参数。声明如下:Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long Const SND_SYNC = &H0 ' 同步播放 Const SND_ASYNC = &H1 ' 异步播放 Const SND_NOSTOP = &H10 '不停止当前播放的任何声音参见MSDN
调用如下:dim Ret as Long Ret=PlaySound("c:\ccc.wav",0&,SND_ASYNC OR SND_NOSTOP)
If Wait Then
Call PlaySound(FileName, 0&, SND_FILENAME)
Else
Call PlaySound(FileName, 0&, SND_ASYNC Or SND_FILENAME)
End If
End Sub
call PlaySoundFile1
按一下按钮出一下声音用那个控件,如果没有其它需要,那太浪费了,且效果不好
这个函数是自己做的吗??我怎么没在msdn里找到??
新建一Module
Declare Function CreateThread Lib "kernel32" (lpThreadAttributes As Any, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, lpParameter As Any, ByVal dwCreationFlags As Long, lpThreadID As Long) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As LongSub main()
Load Form1
Form1.Show
End Sub
Public Sub c1()
.......
End SubPublic Sub c2()
......
End Sub新建一窗体Private hthread1 As Long
Private hthread2 As Long
Private ithread1 As Long
Private ithread2 As LongPrivate Sub Command1_Click()ithread1 = CreateThread(ByVal 0&, ByVal 0&, AddressOf c1, ByVal 0&, ByVal 0&, hthread1) --创建线程一
ithread2 = CreateThread(ByVal 0&, ByVal 0&, AddressOf c1, ByVal 0&, ByVal 0&, hthread1) --创建线程二CloseHandle ithread1 --关闭线程一
CloseHandle ithread2 --关闭线程二End Sub
就用一个API函数就可以,要注意一下参数。声明如下:Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long Const SND_SYNC = &H0 ' 同步播放
Const SND_ASYNC = &H1 ' 异步播放
Const SND_NOSTOP = &H10 '不停止当前播放的任何声音参见MSDN
Ret=PlaySound("c:\ccc.wav",0&,SND_ASYNC OR SND_NOSTOP)