|
 |
推荐文章 |
|
|
|
|
|
|
|
|
|
|
| 作者:本站收集 日期:2005-8-4 11:32:51 |
|
|
Option Explicit
Private Declare Function OSGetLongPathName Lib "VB5STKIT.DLL" Alias "GetLongPathName" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
Public Declare Function OSGetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
Function GetLongPathName(ByVal strShortPath As String) As String
Const cchBuffer = 300
Dim strLongPath As String
Dim lResult As Long
On Error GoTo 0
strLongPath = String(cchBuffer, Chr$(0))
lResult = OSGetLongPathName(strShortPath, strLongPath, cchBuffer)
If lResult = 0 Then
GetShortPathName = ""
Else
GetLongPathName = StripTerminator(strLongPath)
End If
End Function
Public Function GetShortPathName(ByVal strLongPath As String) As String
Const cchBuffer = 300
Dim strShortPath As String
Dim lResult As Long
On Error GoTo 0
strShortPath = String(cchBuffer, Chr$(0))
lResult = OSGetShortPathName(strLongPath, strShortPath, cchBuffer)
If lResult = 0 Then
GetShortPathName = ""
Else
GetShortPathName = StripTerminator(strShortPath)
End If
End Function
'-----------------------------------------------------------
' 函数: StripTerminator
'
' 返回非零结尾的字符串。典型地,这是一个由 Windows API 调用返回的字符串。
'
' 入口: [strString] - 要删除结束符的字符串
'
' 返回: 传递的字符串减去尾部零以后的值。
'-----------------------------------------------------------
'
Private Function StripTerminator(ByVal strString As String) As String
Dim intZeroPos As Integer
intZeroPos = InStr(strString, Chr$(0))
If intZeroPos > 0 Then
StripTerminator = Left$(strString, intZeroPos - 1)
Else
StripTerminator = strString
End If
End Function |
|
|
|
|
|
特别声明: 本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。 |
|
|
|
|
|
责任编辑: 原点 |
投稿作者: 本站收集 |
|
|
信息来源: 网络 |
录入时间: 2005-8-4 11:32:51 |
|
|
|
| |
|