VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 取得短文件名
发表评论(0)作者:, 平台:, 阅读:10272, 日期:2000-03-12
取得短文件名

如果要传递文件到老的不支持长文件名的应用,以下的函数可以派上用场:

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


Function ShortName(LongPath As String) As String

Dim ShortPath As String

Const MAX_PATH = 260

Dim ret&

ShortPath = Space$(MAX_PATH)

ret& = GetShortPathName(LongPath, ShortPath, MAX_PATH)

If ret& Then

ShortName = Left$(ShortPath, ret&)

End If

End Function