打开一个声音文件,用于其它 _Sound 函数.
#include <Sound.au3>
_SoundOpen ( $sFile )
$sFile | 声音文件路径 |
成功: | 返回一个包含下列信息的三元素数组: |
$array[0] = 声音文件 ID 字符串 | |
$array[1] = VBR 长度修正数 | |
$array[2] = VBR 速度修正数 | |
$array[3] = Sound ID marker | |
失败: | 返回 0 并设置 @Error |
@error: | 1 = MCI 错误 |
2 = 文件不存在 | |
@Extended: | 0 = 没有错误. |
大于0 = MCI 错误. |
#include <Sound.au3>
Local $aSound = _SoundOpen(@WindowsDir & "\media\tada.wav")
If @error = 2 Then
MsgBox(4096, "错误", "文件不存在")
Exit
ElseIf @extended <> 0 Then
Local $iExtended = @extended ;赋值, 因为 @extended 可能会在 DllCall 后被设置成其它返回值
Local $tText = DllStructCreate("char[128]")
DllCall("winmm.dll", "short", "mciGetErrorStringA", "str", $iExtended, "ptr", DllStructGetPtr($tText), "int", 128)
MsgBox(4096, "错误", "The open failed." & @CRLF & "Error Number: " & $iExtended & @CRLF & "Error Description: " & DllStructGetData($tText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
Else
MsgBox(4096, "Success", "The file opened successfully")
EndIf
_SoundClose($aSound)