LongFileNm->ShrtFileNmVB6

Konversi Long File Name menjadi Short File Name (VB6)

links: http://www.andreavb.com/tip030009.html

:: How to Convert Long File Name to Short File Name

Author

David Costelloe

Language

VB5, VB6

Operating Systems

Windows 95, 98 and NT
API Declarations

‘ API Declare
Private Declare Function GetShortPathName Lib “kernel32.dll” Alias “GetShortPathNameA” (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long

Module

Public Function ShortName(LongPath As String) As String
‘***************************************************************************
‘ Converts Long FileName to Short FileName
‘***************************************************************************

Dim ShortPath As String
Dim Ret As Long
Const MAX_PATH = 260

If LongPath = “” Then
Exit Function
End If
ShortPath = Space$(MAX_PATH)
Ret = GetShortPathName(LongPath, ShortPath, MAX_PATH)
If Ret Then
ShortName = Left$(ShortPath, Ret)
End If
End Function

Usage

‘Usage:
Private Sub Command1_Click()
MsgBox ShortName(“C:Program FilesMicrosoft Visual StudioLongexecutable.EXE”)
‘ Good for Shell uses or Name etc
End Sub

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: