怎样把如 c:\Program Files\ 这样的路径转换为 c:\Progra~1\

解决方案 »

  1.   


    '*************************************************************************
    '**
    '** 函 数 名:GetShortPath
    '** 返 回 值:As String
    '** 参数说明:strFileName,长路径名
    '** 作    用:将长路径、文件名转换成短路径/文件名
    '**
    '*************************************************************************
    Private Function GetShortPath(strFileName As String) As String
        Dim lngRes As Long, strPath As String
        'Create a buffer
        strPath = String$(165, 0)
        'retrieve the short pathname
        lngRes = GetShortPathName(strFileName, strPath, 164)
        'remove all unnecessary chr$(0)'s
        GetShortPath = Left$(strPath, lngRes)
        GetShortPath = Replace(GetShortPath, Chr(0), "")
    End Function
      

  2.   

    感谢roger_xiong(卖女孩的小火柴~)