converting long filename paths to short 
Author Message
 converting long filename paths to short

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."

Is there any way to do this without having to examine each folder/file name
and manually converting it?

Many thanks.

jon



Fri, 28 Jul 2000 03:00:00 GMT  
 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



Fri, 28 Jul 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Converting a Long FIleName to it's short equivalent (Both possible shorts)

2. Convert long filenames to short filenames

3. Convert Long Filenames to Short Filenames in VB4 16-Bit

4. Converting long filenames to short filenames in VB4.0 16-bit

5. Long and short path- and filenames

6. Converting a Long Filename to Short.?

7. Converting long filenames to short

8. NEW: Converting long filenames to short

9. Convert Long Path to Short

10. SHORT filename to LONG filename???

11. Short Filename to Long Filename ???

12. Long Filename -> Short Filename

 

 
Powered by phpBB® Forum Software