PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, 
Author Message
 PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP,

Quote:

>How do I convert a long file name to a short filename in V.B. 6. Or =
>is`nt it possible?

Put the following declaration in the General Declarations section of the form:

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

Use this code to retrieve the short name (Note: the file must exist to use
this function):

    Dim sLongName As String, sShortName As String
    Dim lRet As Long, lLen As Long
                'Change this to the name of your file.
    sLongName = "c:\program files\microsoft Visual Basic\autocomplete.vbp"
    sShortName = Space$(255)
    lLen = 255
    lRet = GetShortPathName(sLongName, sShortName, lLen)
    sShortName = Left$(sShortName, lLen)

Lee Weiner
weiner AT fuse DOT net
http://www.*-*-*.com/



Mon, 03 Dec 2001 03:00:00 GMT  
 PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP,
Ioan,

You can use the GetShortPathName API function to retrieve the short file
name from a long file name.  Here is an example of converting a text file
named "LongFileName.txt" to it's short file name:

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

Private Sub Command1_Click()

    Dim LongPath As String, ShortPath As String, Length As Long

    LongPath = String(255, vbNullChar)
    ShortPath = String(255, vbNullChar)

    LongPath = App.Path & "\LongFileName.txt"

    Length = GetShortPathName(LongPath, ShortPath, Len(ShortPath))

    ShortPath = Left(ShortPath, Length)
    MsgBox ShortPath

End Sub

In VB5's API Text Viewer the declaration for this API is incorrect.  The
declaration I have above is correct.

Hope this helps,

Kerry Moorman



How do I convert a long file name to a short filename in V.B. 6. Or is`nt
it possible?

----------



Mon, 03 Dec 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Can anyone HELP me PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE

2. PLEASE HELP PLEASE HELP PLEASE HELP

3. Design Help PLEASE PLEASE PLEASE!

4. Please Please PLEASE HELP!!!!!

5. URGENT HELP PLEASE PLEASE PLEASE???

6. Please please please, help me :-)

7. Please, Please, Please I need help working with dates

8. Please, please, please help!!

9. Cloning problem -- please please please help

10. Please, please, please, help!

11. Please, Please, Please I need your help with Winsock

12. Help Please Please Please

 

 
Powered by phpBB® Forum Software