|
Private Declare Function GetShortPathName Lib "kernel32" _
Alias "GetShortPathNameA" (ByVal lpszLongPath As String, _
ByVal lpszShortPath As String, _
ByVal cchBuffer As Long) As Long
Function ShortPath(ByVal FileName As String, Optional MaxLen As Long = 255) As String
Dim ID As Long
ShortPath = String(MaxLen, " ")
GetShortPathName FileName, ShortPath, MaxLen
ID = InStr(ShortPath, Chr(0))
If ID > 0 Then ShortPath = Left(ShortPath, ID - 1)
End Function
SUB TEST()
DIM MP3 AS STRING
MP3="C:\AB 22.MP3"
'要真实的MP3文件,缩短路径用的
MP3=ShortPath(MP3)
MSGBOX MP3
END SUB
|
|