www.pudn.com > MIC.ZIP > MCIPlay.frm
VERSION 5.00
Begin VB.Form frmMain
Caption = "播放多媒体文件"
ClientHeight = 3285
ClientLeft = 60
ClientTop = 345
ClientWidth = 4890
LinkTopic = "Form1"
LockControls = -1 'True
ScaleHeight = 3285
ScaleWidth = 4890
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton Command1
Caption = "播放"
Height = 495
Left = 240
TabIndex = 5
Top = 2640
Width = 1335
End
Begin VB.CommandButton Command2
Caption = "停止播放"
Height = 495
Left = 2160
TabIndex = 4
Top = 2640
Width = 1455
End
Begin VB.FileListBox File1
Height = 1890
Left = 2160
Pattern = "*.wav;*.mid;*.avi"
TabIndex = 2
Top = 480
Width = 2535
End
Begin VB.DirListBox Dir1
Height = 1560
Left = 240
TabIndex = 1
Top = 960
Width = 1815
End
Begin VB.DriveListBox Drive1
Height = 300
Left = 240
TabIndex = 0
Top = 480
Width = 1815
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "请选择.wav.mid.avi文件"
Height = 180
Left = 120
TabIndex = 3
Top = 120
Width = 2412
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command1_Click()
Dim PathName As String, S As String, ShortPathName As String
PathName = File1.Path
If Right(PathName, 1) <> "\" Then PathName = PathName & "\"
PathName = PathName & File1.filename
S = String(LenB(PathName), Chr(0))
GetShortPathName PathName, S, Len(S)
ShortPathName = Left(S, InStr(S, Chr(0)) - 1)
mciSendString "close MyWav", vbNullString, 0, 0
mciSendString "open " & ShortPathName & " alias MyWav", vbNullString, 0, 0
mciSendString "play MyWav", vbNullString, 0, 0
End Sub
Private Sub Command2_Click()
mciSendString "close MyWav", vbNullString, 0, 0
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub Form_Unload(Cancel As Integer)
mciSendString "close MyWav", vbNullString, 0, 0
End Sub