TAG:
[声明API函数] Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long '播放WAV所需要的声明 '检测声卡所需要的声明 Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long Private Declare Function auxGetNaumDevs Lib "MMSYSTEM.dll″()as Integer" () '所用到的全局变量声明 Private Const SND_ALIAS = &H10000 ' name is a WIN.INI [sounds] entry Private Const SND_ALIAS_ID = &H110000 ' name is a WIN.INI [sounds] entry identifier Private Const SND_ALIAS_START = 0 ' must be > 4096 to keep strings in same section of resource file Private Const SND_APPLICATION = &H80 ' look for application specific association Private Const SND_ASYNC = &H1 ' play asynchronously Private Const SND_FILENAME = &H20000 ' name is a file name Private Const SND_LOOP = &H8 ' loop the sound until next sndPlaySound Private Const SND_MEMORY = &H4 ' lpszSoundName points to a memory file Private Const SND_NODEFAULT = &H2 ' silence not default, if sound not found Private Const SND_NOSTOP = &H10 ' don't stop any currently playing sound Private Const SND_NOWAIT = &H2000 ' don't wait if the driver is busy Private Const SND_PURGE = &H40 ' purge non-static events for task Private Const SND_RESERVED = &HFF000000 ' In particular these flags are reserved Private Const SND_RESOURCE = &H40004 ' name is a resource name or atom Private Const SND_SYNC = &H0 ' play synchronously (default) Private Const SND_TYPE_MASK = &H170007 Private Const SND_VALID = &H1F ' valid flags / ;Internal / Private Const SND_VALIDFLAGS = &H17201F ' Set of valid flag bits. Anything outside '3.在Form1上添加一个命令按钮控件,采用缺省的方法建立Command1。 '将它的Caption属性设置为“播放文件”。 '4.将如下的代码添加到Command1的单击事件中: Private Sub Comman2_Click() CmdStr$ = "play c:\\Cbt_demo.avi fullscreen " ReturnVal& = mciSendString(CmdStr$, 0&, 0, 0&) End Sub Private Sub Command1_Click() Dim Flag As Long Dim a As Long Flag = SND_ASYNC Or SND_LOOP Print Flag a = sndPlaySound("c:\\02.wav", Flag) End Sub Private Sub Command3_Click() Dim Flag As Long Dim a As Long Flag = SND_ASYNC Print Flag a = sndPlaySound("c:\\a.wav", Flag) End Sub (iwgh) |