How to retrieve the full long path name from short path (MS Dos format)
Posted on November 10, 2011
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 'System & API - How to retrieve the full long path name from short path (MS Dos format) Option Explicit Private Const MAX_PATH As Long = 260 Private Declare Function GetLongPathName Lib "kernel32" _ Alias "GetLongPathNameA" _ (ByVal lpszShortPath As String, _ ByVal lpszLongPath As String, _ ByVal cchBuffer As Long) As Long Private Function GetLongName(strTest As String) As String Dim sLongPath As String Dim buff As String Dim cbbuff As Long Dim result As Long buff = Space$(MAX_PATH) cbbuff = Len(buff) result = GetLongPathName(strTest, buff, cbbuff) If result > 0 Then sLongPath = Left$(buff, result) End If GetLongName = sLongPath End Function Private Sub Command1_Click() Dim strShortFile As String strShortFile = "C:\DOCUME~1\jamster\Desktop\MYFILE~1.TXT" Debug.Print "File Name "; GetLongName(strShortFile) End Sub |