GetShortPathName Function

GetShortPathName Lib "kernel32.dll" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, lpszShortPath As String, ByVal cchBuffer As Long) As Long

GetShortPathName converts a long filename into the old-style 8.3 filenames. Although Windows 95 allows the use of long filenames, DOS programs, not to mention 16-bit Windows programs, must use the 8.3 equivalent. For example, the equivalent of ReallyLongFile.txt could be REALLY~1.TXT. The short filename is put into the string variable passed as lpShortPath. The function returns the length of the string, or 0 if the function failed.

lpszLongPath
The complete long path and filename to convert.
lpszShortPath
A fixed-length string which receives the short filename equivalent.
cchBuffer
The size in characters of lpszShortPath.

Example:

' Convert C:\My Documents\RichTextOne.rtf to its short equivalent
Dim buffer As String * 255
x = GetShortPathName("C:\My Documents\RichTextOne.rtf", buffer, 255)
Debug.Print Left(buffer, x)  ' could be C:\MYDOCU~1\RICHTE~1.RTF

Related Call: GetFullPathName
Category: Files
Back to the index.


Back to Paul Kuliniewicz's Home Page
E-mail: Borg953@aol.com
This page is at http://members.aol.com/Borg953/api/functions/getshortpathname.html