
Q: SendTo and short/long filenames?
Converting Short Long Filenames to Short:
' Use as follows:
' LongFilename=GetLongFilename(ShortFilename)
Public Function GetLongFilename(FileName As String) As String
' Capitalizes the correct parts of the filename and replaces any short
filename with long ones
Dim CurrentPath As String, Remaining As String
Dim FirstPart As String, CurrentFolder As String, Start As Integer
Remaining = FileName
CurrentPath = vbNullString
Start = InStr(InStr(FileName, ":\") + 2, FileName, "\")
If Start > 0 Then
CurrentPath = Mid$(FileName, 1, Start - 1)
Else
CurrentPath = FileName
End If
Remaining = FileName
Do
FirstPart = ExtractPath(CurrentPath)
CurrentFolder = ExtractFileName(CurrentPath)
CurrentPath = FirstPart & "\" & Dir(CurrentPath, vbDirectory)
If Remaining = FileName Then
' First Time
Remaining = Mid$(Remaining, Len(FirstPart) + 2)
End If
Remaining = Mid$(Remaining, Len(CurrentFolder) + 2)
If Remaining <> vbNullString Then
CurrentPath = CurrentPath & "\" & ExtractFirstFolder(Remaining)
End If
Loop Until Remaining = vbNullString
If InStr(CurrentPath, ":\") > 0 Then Mid$(CurrentPath, 1, 1) =
UCase$(Mid$(CurrentPath, 1, 1))
GetLongFilename = CurrentPath
End Function
Public Function ExtractFileName(PathAndFileName As String) As String
Dim PathName As String, i As Integer
ExtractFileName = vbNullString
PathName = Trim$(PathAndFileName)
For i = Len(PathName) To 1 Step -1
If Mid$(PathName, i, 1) = "\" Or Mid$(PathName, i, 1) = "/" Then
Exit For
Next i
If Len(PathName) > i Then ExtractFileName = Mid$(PathName, i + 1)
End Function
Public Function ExtractPath(PathAndFileName As String) As String
Dim PathName As String, i As Integer
ExtractPath = vbNullString
PathName = Trim$(PathAndFileName)
For i = Len(PathName) To 1 Step -1
If Mid$(PathName, i, 1) = "\" Or Mid$(PathName, i, 1) = "/" Then
Exit For
Next i
If i > 0 Then ExtractPath = Mid$(PathName, 1, i - 1)
End Function
Public Function ExtractFirstFolder(Path As String) As String
If InStr(Path, "\") > 0 Then
ExtractFirstFolder = Mid$(Path, 1, InStr(Path, "\") - 1)
Else
ExtractFirstFolder = Path
End If
End Function
*************************
Note:
If you want to pass the long filename to your program by association in the
registry, enter the commandline value as "c:\filename.exe %l" (lowercase L)