Friday, June 8, 2012

Mengubah Format DOS 8.3 menjadi Long Filename

Mengubah format DOS 8.3 menjadi long filename, contohnya: G:\PROJEC~1\BILLIN~1\BILLIN~1\Client\CLIENT~1.EXE menjadi: G:\Project-ku\Billing Warnet\Billing Warnet\Client\Client Cafe.exe. Nah bagaimana kode konversi format DOS 8.3 ini, bisa Anda perhatikan di bawah:
Option Explicit 

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

Public Function
GetLongPath(ByVal Filename As String) As String
On Error Resume Next
Dim
length As Long
Dim s As String
s =
String$(MAX_PATH, 0)
length = GetLongPathName(Filename, s, Len(s))
If (length And Err = 0) Then GetLongPath = Left$(s, length)
End Function
Contoh penggunaan kode di atas:
Private Sub Command1_Click() 
MsgBox GetLongPath("G:\PROJEC~1\BILLIN~1\BILLIN~1\Client\CLIENT~1.EXE")
End Sub