调用:
Print 取8_3路径("C:\Program Files\Internet Explorer\Iexplore.exe")
以下代码放在 BAS 模块文件中.
---------------------------
public Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
public Function 取8_3路径(原始路径 As String) As String
Dim m As Long
Dim path As String
Const pathlen& = 164 '定义一个常量
path = String$(pathlen + 1, 0) '申请返回值的内存空间为 最大长度 + 1 .C 规定,字符串以 \0 结束字符串占用内存比字符串长度多 1
'调用API函数,转为 8.3 短格式,需要存在这个文件,
'API函数,返回结果是有字符串长度,参数1 为 路径, 参数2 是内存起始地址, 参数3 是内存空间长度
m = GetShortPathName(原始路径, path, pathlen)
取8_3路径 = Left$(path, m)
End Function