Results 1 to 2 of 2

Thread: how to find the MS-Dos name

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2000
    Posts
    49
    Is there a good API function that can give you a folder 's name in ms-dos
    EXAMPLE: the folder Program files is named PROGRAM~1 in dos.

  2. #2
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    Why, of course there is!
    Code:
    Option Explicit
    
    Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
    
    Function GetShortName(ByVal sPath As String) As String
        Dim lPos As Long
        
        GetShortName = String(Len(sPath), vbNullChar)
        Call GetShortPathName(sPath, GetShortName, Len(sPath) + 1)
        
        lPos = InStr(GetShortName, vbNullChar)
        If lPos Then GetShortName = Left(GetShortName, lPos - 1)
    End Function
    The GetShortName implementation returns the short name of a path/file, or an empty string if the file doesn't exist.
    Example:
    Code:
    MyPath = GetShortName("C:\Program Files") ' On most computers, this returns "C:\PROGRA~1"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width