我按照各位给出的意见已经改完了,但是还是不好用,这次能强很多,但是点击播放没有反应,也不出声音!请帮忙再次指点指点,谢谢了!! 以下附上代码
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
Private Declare Function mciGetErrorString Lib _
"winmm.dll" Alias "mciGetErrorStringA" ( _
ByVal dwError As Long, _
ByVal lpstrBuffer As String, _
ByVal uLength As Long) As Long
Private Declare Function GetShortPathName Lib _
"kernel32" Alias "GetShortPathNameA" ( _
ByVal lpszLongPath As String, _
ByVal lpszShortPath As String, _
ByVal cchBuffer As Long) As Long
Private Sub cmdOpen_Click()
Dim fileName As String
Dim strl As String
Dim mciCommand As String
Dim shortName As String
Dim err As Long
Dim errStr As String
On Error GoTo errhandler
comDlg.fileName = ""
comDlg.Filter = " *.mp3| *.mp3"
comDlg.ShowOpen
fileName = comDlg.fileName
lbPath.Caption = comDlg.fileName
strl = String(LenB(fileName), Chr(0))
GetShortPathName fileName, strl, Len(strl)
shortName = Left(strl, InStr(strl, Chr(0)) - 1)
mciSendString "close openFile", vbNullString, 0, 0
mciCommand = "open" & shortName & "alias openFile type MPGEVideo"
err = mciSendString(mciCommand, vbNullString, 0, 0)
Exit Sub
errhandler:
mciGetErrorString err, errStr, 1024
MsgBox errStr
End Sub
Private Sub cmdExit_Click()
mciSendString "close openFile", vbNullString, 0, 0
End
End Sub
Private Sub cmdPlay_Click()
mciSendString "play openFile", vbNullString, 0, 0
End Sub
Private Sub cmdPause_Click()
mciSendString "pause openFile", vbNullString, 0, 0
End Sub
Private Sub cmdstop_Click()
mciSendString "stop openFile", vbNullString, 0, 0
End Sub