寫的 帶聲的按鈕,宣告函式的程序代碼 如下:
Dim rt As Long
''Get the path name
AppPath = App.Path
If Right$(AppPath, 1) <> "\" Then
AppPath = AppPath & "\"
End If
''Allocate space for short path name
ShortPathName = Space$(255)
''Get the short path name since MCI only accepts those
GetShortPathName AppPath, ShortPathName, Len(ShortPathName)
''Remove empty spaces and the trailing NULL character
ShortPathName = Left$(ShortPathName, Len(Trim$(ShortPathName)) - 1)
'Build the command string
CommandString = "OPEN " & ShortPathName & FileName & " TYPE WAVEAUDIO ALIAS " & Alias
'Open the sound
rt = mciSendString(CommandString, 0&, 0, 0)
If rt <> 0 Then ''Non 0 = error
Errorstring = Space$(255)
mciGetErrorstring rt, Errorstring, Len(Errorstring
MsgBox "Error: " & Errorstring
End If
End Sub
Public Sub StopSounds()
mciSendString "STOP " & MouseOverMCI, 0&, 0, 0
mciSendString "STOP " & MouseUpMCI, 0&, 0, 0
mciSendString "STOP " & MousePressMCI, 0&, 0, 0
End Sub
'**********===================
uj5u.com熱心網友回復:
可能是上一次呼叫MCI介面時還未執行完畢,正忙,無法回應播放指令吧.試試用PlaySound函式播放音頻吧,效率比起呼叫MCI介面要高不少,但缺點是只能播放WAV檔案(貌似是這樣).
不過由于可以播放記憶體音頻,所以在集成方面比較有優勢,可以將要播放的聲效轉為WAV再放到資源檔案里,程式啟動時讀到位元組陣列,就可以播放了,不需要物體檔案的存在
uj5u.com熱心網友回復:
在改變當前路徑之后,記得在退出程序前將當前路徑恢復到 App.Path,如果你的 DLL 函式是用相對地址宣告的話:ChDir App.Path
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/127645.html
標籤:API
上一篇:windows關機死回圈腳本代碼
