原始碼:http://down.gogobox.com.tw/t2329175/qq2m2
用VB6做的簡易播放器,
有OLE的功能。
程式碼:

Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" _
(ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long

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 Sub Command1_Click()
On Error Resume Next
Dim S As String, S1 As String
'S1=音樂檔(wav,mp3,mid...)
S1 = PlayPath
'將長檔名改成短檔名
S = String(LenB(S1), Chr(0))
GetShortPathName S1, S, Len(S)
S = Left(S, InStr(S, Chr(0)) - 1)
'關掉之前播放的媒體
mciSendString "close MyWav", vbNullString, 0, 0
'打開媒體
mciSendString "open " & S & " alias MyWav", vbNullString, 0, 0
'開始播放
mciSendString "play MyWav", vbNullString, 0, 0
End Sub

Private Sub Command2_Click()
On Error Resume Next
'關掉媒體
mciSendString "close MyWav", vbNullString, 0, 0
End Sub

Private Sub Command3_Click()
On Error Resume Next
'取得路徑
CD1.ShowOpen
If CD1.FileName <> "" Then PlayPath = CD1.FileName
End Sub

Private Sub Form_Load()
'初始化對話物件
CD1.Filter = "多媒體檔案(*.wav;*.mp3;*.wma;*.mid)|*.wav;*.mp3;*.wma;*.mid"
End Sub

Private Sub PlayPath_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
'OLE設定
PlayPath = Data.Files.Item(1)
End Sub

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 讓地獄深紅的天亮 的頭像
    讓地獄深紅的天亮

    !壞人必需做好事!

    讓地獄深紅的天亮 發表在 痞客邦 留言(1) 人氣()