# Re: Mult-Media如何读取多媒体档案的长度?

Posted by Sun Jack on September 11, 1999 at 20:23:58:

In Reply to: Mult-Media如何读取多媒体档案的长度? posted by ComBilLi on September 10, 1999 at 22:40:41:

: Mult-Media如何读取多媒体档案的长度?
: 或
: 用一个Multi-Media control开一个Wav file，如何知道这Wav file有多少时间?

Option Explicit
Private Declare Function mciSendString Lib "winmm.dll" Alias _
"mciSendStringA" (ByVal lpstrCommand As String, ByVal _
lpstrReturnString As Any, ByVal uReturnLength As Long, ByVal _
hwndCallback As Long) As Long

Private Sub Form_Load()
Dim RS As String
Dim i As Long
Dim TotalLen As Long
Dim Position As Long
RS = Space$(128)
i = mciSendString("open h:\test.wav alias Wave ", RS, 128, 0)
i = mciSendString("status Wave length wait", RS, 128, 0)
Position = InStr(RS, vbNullChar)
TotalLen = Left(RS, Position - 1)
MsgBox "Total milliseconds:" & TotalLen
i = mciSendString("close Wave ", RS, 128, 0)
End Sub

Follow Ups: