Want to convert Dir in as long file name to short file name string? How? 
Author Message
 Want to convert Dir in as long file name to short file name string? How?

Hello Scrufffy,

Yes, you can convert a long file name to its short equivalant.  Just use
this simple API call:

Declare Function GetShortPathName Lib "kernel32" _
    Alias "GetShortPathName" _
    (ByVal lpszLongPath As String, _
     ByVal lpszShortPath As String, _
     ByVal cchBuffer As Long) As Long

To use the API, fill the lpszLongPath string with the long file path (full
path including drive letter), and fill the lpszShortPath variable to 256
characters with the Space() function.  Set the value of the cchBuffer long
to 255 (the current length of the short path variable including space for
the null terminator that the API call will append to the end of the string)
and call the function, like so:

Dim lpszLongPath as String
Dim lpszShortPath as String
Dim cchBuffer as Long
Dim lrtVal as Long

lpszLongPath = "C:\Program Files\DevStudio\VB\VB5.EXE"
lpszShortPath = Space(256)
cchBuffer = 255

lrtVal = GetShortPathName(lpszLongPath, lpszShortPath, cchBuffer)
If lrtVal = 0 Then
    ' Function completed successfully, lpszShortPath contains
    ' valid value for the short path name, strip the null
    ' terminator
    lpszShortPath = Left(lpszShortPath, cchBuffer)
Else
    ' a non-zero return value means that the function call
    ' failed.  raise an error or do something
    lpszShortPath = ""
    Beep
End If

I hope this helps,

Larry R. Tubbs Jr., MCPS, MCSD
Silverleaf Resorts Inc, NYSE: SVR

Quote:

>Want to convert Dir in as long file name to short file name string as
>the dos app I am tryin to run does not support long file names.
>How can I conver the dir string I have so it is a short filename
>convention?

>Any Help would be most appreciated
>Please e-mail me or reoly in news group

>Thanx Scrufffy




Fri, 23 Jun 2000 03:00:00 GMT  
 Want to convert Dir in as long file name to short file name string? How?

This didn't work... if anyone got this to work, could you send me a
project?

Quote:

> >Want to convert Dir in as long file name to short file name string as
> >the dos app I am tryin to run does not support long file names.
> >How can I conver the dir string I have so it is a short filename
> >convention?

> >Any Help would be most appreciated
> >Please e-mail me or reoly in news group

> >Thanx Scrufffy


REMOVE NOSPAM
-- Ryan Martinsen

-- http://members.xoom.com/srm/

When you see a man on top of a mountain, he didn't just fall there.



Wed, 28 Jun 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Converting Long File Names to Short File Names

2. How to convert long file names to short file names

3. Api function to convert Long File Names To Short Dos File Names

4. Convert Long Folder Names to DOS Short Dir Names

5. Get long file name from short file name

6. Long File Names and Short File Names

7. Get Short File Name from Long File Name?

8. Long file names to short file name

9. Getting short file name from long file name:

10. long file names to short file name

11. Long File Names and Short File Names

12. Short File Name to Long File Name

 

 
Powered by phpBB® Forum Software