
converting long filename paths to short
Quote:
> Is there any way to do this without having to examine each folder/file
name
> and manually converting it?
Due to the way Win95 and WinNT handle Long Filenames, you *cannot* manually
convert pathnames. MS provides a function to read the filename lookup
table and find the entry for a given Long Filename. This API function is
GetShortPathName.
' Type all on one line:
Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA"
(ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal
cchBuffer As Long) As Long
This is different than what comes out of the original API Viewer... the
alias was incorrect, so I fixed it.
Dim sLongPath As String
Dim sShortPath As String
Dim LenPath As Long, rVal As Long
LenPath = 255
sShortPath = String$(LenPath, 0)
sLongPath = "Some really long path and file name"
rVal = GetShortPathName(sLongPath, sShortPath, LenPath)
sShortPath = Left$(sShortPath, rVal)
MSDN:
"If the function fails due to the lpszShortPath buffer being too small to
contain the short path string, the return value is the size, in characters,
of the short path string. You need to call the function with a short path
buffer that is at least as large as the short path string. If the function
fails for any other reason, the return value is zero. To get extended error
information, call GetLastError."
see ya.
--
Jim Houghtaling
One-seventh of your life will be spent on Mondays.
Quote:
> Is there any way to convert an LFN path into something that non-LFN-aware
> applications will understand?
> Currently, I'm using the saveOpen method of a common dialog control to
> retrieve a full path, but the full path is currently in the format
"K:\ocr
> test\output\output.txt." I need to put this path into an .ini file for a
> 16-bit app in the format "K:\ocrtes~1\output\output.txt."
> Many thanks.
> jon