Is there a good API function that can give you a folder 's name in ms-dos
EXAMPLE: the folder Program files is named PROGRAM~1 in dos.
Printable View
Is there a good API function that can give you a folder 's name in ms-dos
EXAMPLE: the folder Program files is named PROGRAM~1 in dos.
Why, of course there is! :rolleyes:
The GetShortName implementation returns the short name of a path/file, or an empty string if the file doesn't exist.Code:Option Explicit
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
Function GetShortName(ByVal sPath As String) As String
Dim lPos As Long
GetShortName = String(Len(sPath), vbNullChar)
Call GetShortPathName(sPath, GetShortName, Len(sPath) + 1)
lPos = InStr(GetShortName, vbNullChar)
If lPos Then GetShortName = Left(GetShortName, lPos - 1)
End Function
Example:
Code:MyPath = GetShortName("C:\Program Files") ' On most computers, this returns "C:\PROGRA~1"