I'm attempting to shell off to another application and the other app doesn't support long file names. Is there a way to obtain the associated 8.3 file name programmatically?
From: Shamil Salakhetdinov <shamil@marta.darts.spb.ru>
To: ACCESS-L <ACCESS-L@PEACH.EASE.LSOFT.COM>
Subject: Re: Getting the 8.3 file Name associated With a Long File Name
Date: 19 February 1999 14:24
Here is the function built on top of GetShortPathName API32 call:
Private Declare Function smsGetShortPathName& _
Lib "Kernel32" Alias "GetShortPathNameA" _
(ByVal lpszLongPath As String, _
ByVal lpszShortPath As String, _
ByVal cchBuffer As Long)
Public Function ShortPathNameGet(ByVal vstrLongPath As String) As String
'
' written by Shamil Salakhetdinov: shamil@marta.darts.spb.ru
'
Dim strTmpBuf As String * 512
Dim lngTmpBufLen As Long
Dim lngRet As Long
lngTmpBufLen = 512
lngRet = smsGetShortPathName(vstrLongPath, strTmpBuf, lngTmpBufLen)
If lngRet = 0 Then
Err.Raise 503 + vbObjectError, "ShortPathNameGet", _
"File not found: " & vstrLongPath
ElseIf lngTmpBufLen < lngRet Then
Err.Raise 503 + vbObjectError, "ShortPathNameGet", _
"File path greater than temp buffer: " & _
lngRet & " > " & lngTmpBufLen
End If
ShortPathNameGet = Left(strTmpBuf, lngRet)
End Function
| HOME TOPICS |
Copyright © 1999 by Shamil Salakhetdinov.
|
| Last updated: October 10, 2006
Published also here at 4TOPS: Getting the 8.3 file Name associated With a Long File Name |
|