'在VB之下直接使用
Private Sub Command1_Click()
FileCopy "C:\Program Files\testa b\cmd.txt", "c:\cmd.txt"
End Sub
'********************************
'shell(DOS命令)时要将长文件名改为短文件名
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()
FileCopy Getshortname("C:\Program Files\testa b") & "\cmd.txt", "c:\cmd.txt"
End Sub
Public Function Getshortname(ByVal sLongFileName As String) As String
Dim lRetVal&, sShortPathName$, iLen%
sShortPathName = Space(255)
iLen = Len(sShortPathName)
lRetVal = GetShortPathName(sLongFileName, sShortPathName, iLen)
Getshortname = Left(sShortPathName, lRetVal)
jj = InStr(Getshortname, Chr(0))
If jj > 0 Then Getshortname = Mid(Getshortname, 1, jj - 1)
End Function
Public Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long