VB提取文件时候长短路径转化问题??高手解答一下!

来源:百度知道 编辑:UC知道 时间:2024/05/08 20:34:37
代码:
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
Dim AA As String

Private Sub Form_Load()
AA = IIf(Right(App.Path, 1) <> "\" And Right(App.Path, 1) <> "/", App.Path & "\", App.Path) & "音乐\bs.mp3"
mciSendString "play """ & AA & """", vbNullString, 0, 0
End Sub
经测试,工程编译后只能放在:短文件夹内才能播放,比如:program file 或者桌面:C:\Documents and Settings\Administrator...还是不能播放...
还有个问题,我想循环播放音乐怎么办.....
为什么网络音乐,"..url..."工程放那里都可以播放呢???....
长文件路径到底什么意思,我放在自己建立的文件夹:adbfajglkajfkljgalkjgalkj里面,这么长"都可以播放""hehe,具体怎么把这段代码添加到我哪个题目呢??

看看我以前的回答:

VB里怎么连续循环播放MID背景音乐
http://hi.baidu.com/starwork/blog/item/1a8f85dec73d8459cdbf1a23.html

我是丹心,:)

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

'得到文件短文件名
Function ShortName(LongPath As String) As String
Dim ShortPath As String
Dim pos As String
Dim Ret As Long
Const MAX_PATH = 260
If LongPath = "" Then Exit Function
ShortPath = Space$(MAX_PATH)
Ret& = GetShortPathName(LongPath, ShortPath, MAX_PATH)
If Ret& Then
pos = InStr(1, ShortPath, " ")
ShortName = Left$(ShortPath, pos - 2)
End If
End Function