[此贴子已经被作者于2005-11-21 20:19:07编辑过]
[此贴子已经被作者于2005-11-21 20:19:07编辑过]
Dim tianjia As Integer '判断是否从新添加音乐文件
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
Private Sub Command1_Click()
Dim lujing As String
If tianjia = 1 Then
MP3.List1.Clear
MP3.List2.Clear
Dim n As Integer
Dim m As Integer
n = File1.ListCount - 1
For m = 0 To n
If File1.Selected(m) = True Then
lujing = File1.Path & "\" & File1.List(m)
MP3.List1.AddItem File1.List(m)
MP3.List2.AddItem ShortName(lujing)
MP3.List1.Refresh
End If
Next
Unload Me
Else
n = File1.ListCount - 1
For m = 0 To n
If File1.Selected(m) = True Then
lujing = File1.Path & "\" & File1.List(m)
MP3.List1.AddItem File1.List(m)
MP3.List2.AddItem ShortName(lujing)
MP3.List1.Refresh
End If
Next
'播放器.MediaPlayer1.Stop
Unload Me
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub del_Click()
MP3.del_Click
End Sub
Private Sub Form_Load()
tianjia = 1
End Sub
Private Sub Option1_Click()
If Option1.Value = True Then
tianjia = 1
Else
tianjia = 0
End If
End Sub
Private Sub Option2_Click()
If Option2.Value = True Then
tianjia = 0
Else
tianjia = 1
End If
End Sub
Public Function ShortName(LName As String) As String
'取得短文件名
Dim s As String, i As Long
i = 512
s = Space$(i)
GetShortPathName LName, s, i
ShortName = Left(s, InStr(1, s, vbNullChar) - 1)
End Function
我终于做出来了.哈哈^多谢版主们提示.