Visual Basic Programming Code Examples Visual Basic > Files Directories Drives Code Examples Getting the Short Filename Getting the Short Filename Declare Function GetShortPathName Lib "kernel32" _ Alias "GetShortPathNameA" (ByVal lpszLongPath As String, _ ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long Public Function GetShortName(ByVal Filename As String) As String 'Dimension some variables. Dim lRetVal As Long Dim sShortPathName As String Dim iLen As Integer 'Set up buffer area for API function call return sShortPathName = Space(20) iLen = Len(sShortPathName) 'Call the function lRetVal = GetShortPathName(Filename, sShortPathName, iLen) 'Strip away unwanted characters. GetShortName Left(sShortPathName, lRetVal) End Function