请教,VB怎么获取MP3,WMA等音频文件的总时间呢

请问,VB如何获取MP3,WMA等音频文件的总时间呢?请问,VB如何获取MP3,WMA等音频文件的总时间呢?[解决办法]请

请问,VB如何获取MP3,WMA等音频文件的总时间呢?
请问,VB如何获取MP3,WMA等音频文件的总时间呢?

[解决办法]
请看代码,此代码调用了xaudio sdk的win32dll,此dll请自行搜索。

Private Sub cmdGetInfo_Click()
Dim s As String
Dim l As Long
Dim status As Integer
Dim t As XA_InputModule
Dim d As XA_DecoderInfo
Dim dp As Long
Dim opbi As XA_OutputBufferInfo
Dim i As Long

dp = VarPtr(d)
status = decoder_new(VarPtr(dp))
If status <> XA_SUCCESS Then
MsgBox "can not create decoder! "
Exit Sub
End If
CopyMemory VarPtr(d), dp, 60

status = file_input_module_register(t)
status = decoder_input_module_register(d, t)

If status <> XA_SUCCESS Then MsgBox xaudio_error_string(status)
status = decoder_input_new(d, App.Path & "\3.mp3 ", XA_DECODER_INPUT_AUTOSELECT)
If status <> XA_SUCCESS Then
MsgBox "can not create input! " & status & vbCrLf & xaudio_error_string(status)
Exit Sub
End If
status = decoder_input_open(d)
If status <> XA_SUCCESS Then
MsgBox "can not open input! " & vbCrLf & xaudio_error_string(status)
Exit Sub
End If

Dim mp3info As MP3InfoType
Dim l1 As Long, l2 As Long
Dim l3 As Single

Do
DoEvents
status = decoder_decode(d, 0)
CopyMemory VarPtr(opbi), d.Addr06, Len(opbi)

With mp3info.WaveFormat
.BitsPerSample = opbi.bytes_per_sample * 8
.Channels = 2 ^ opbi.stereo
.SamplesPerSec = opbi.sample_rate
End With
l1 = l1 + 1
l2 = l2 + opbi.size
l3 = l3 + opbi.size / (opbi.sample_rate * ((2 ^ opbi.stereo) * opbi.bytes_per_sample))

Loop While status = XA_SUCCESS Or status = XA_ERROR_TIMEOUT Or status = XA_ERROR_INVALID_FRAME

With mp3info
.Frames = l1
.ByteLength = l2
.SecondLength = l3
End With

MsgBox "Frames: " & mp3info.Frames & vbCrLf & "Bytes: " & mp3info.ByteLength & vbCrLf & "Seconds: " & mp3info.SecondLength

l = xaudio_get_api_version(XA_API_ID_SYNC)
MsgBox "XAudio DLL Version: " & ((l \ (2 ^ 16)) And &H255) & ". " & ((l \ (2 ^ 8)) And &H255) & ". " & (l And &H255)
End Sub