Here's the hard way....
[tt]
Private Const RESOURCETYPE_ANY = &H0
Private Const RESOURCE_CONNECTED = &H1
Private Type NETRESOURCE
dwScope As Long
dwType As Long
dwDisplayType As Long
dwUsage As Long
lpLocalName As Long
lpRemoteName As Long
lpComment As Long
lpProvider As Long
End Type
Private Declare Function lstrlen Lib "kernel32" _
Alias "lstrlenA" (ByVal lpString As Any) As Long
Private Declare Function lstrcpy Lib "kernel32" _
Alias "lstrcpyA" (ByVal lpString1 As Any, _
ByVal lpString2 As Any) As Long
Private Declare Function WNetOpenEnum Lib "mpr.dll" _
Alias "WNetOpenEnumA" _
(ByVal dwScope As Long, ByVal dwType As Long, _
ByVal dwUsage As Long, lpNetResource As Any, _
lphEnum As Long) As Long
Private Declare Function WNetEnumResource Lib "mpr.dll" _
Alias "WNetEnumResourceA" _
(ByVal hEnum As Long, lpcCount As Long, _
lpBuffer As Any, lpBufferSize As Long) As Long
Private Declare Function WNetCloseEnum Lib "mpr.dll" _
(ByVal hEnum As Long) As Long
Function LetterToUNC(DriveLetter As String) As String
On Error Resume Next
Dim hEnum As Long
Dim NetInfo(1023) As NETRESOURCE
Dim entries As Long
Dim nStatus As Long
Dim LocalName As String
Dim UNCName As String
Dim i As Long
Dim r As Long
nStatus = WNetOpenEnum(RESOURCE_CONNECTED, _
RESOURCETYPE_ANY, 0&, ByVal 0&, hEnum)
LetterToUNC = DriveLetter
If ((nStatus = 0) And (hEnum <> 0)) Then
entries = 1024
nStatus = WNetEnumResource(hEnum, entries, _
NetInfo(0), CLng(Len(NetInfo(0))) * 1024)
If nStatus = 0 Then
For i = 0 To entries - 1
LocalName = ""
If NetInfo(i).lpLocalName <> 0 Then
LocalName = Space(lstrlen( _
NetInfo(i).lpLocalName _
) + 1)
r = lstrcpy( _
LocalName, NetInfo(i).lpLocalName _
)
End If
If Len(LocalName) <> 0 Then
LocalName = Left(LocalName, _
(Len(LocalName) - 1) _
)
End If
If UCase$(LocalName) = UCase$(DriveLetter) Then
UNCName = ""
If NetInfo(i).lpRemoteName <> 0 Then
UNCName = Space(lstrlen( _
NetInfo(i).lpRemoteName) + 1 _
)
r = lstrcpy( _
UNCName, NetInfo(i).lpRemoteName _
)
End If
If Len(UNCName) <> 0 Then
UNCName = Left( _
UNCName, (Len(UNCName) - 1) _
)
End If
LetterToUNC = UNCName
Exit For
End If
Next i
End If
End If
nStatus = WNetCloseEnum(hEnum)
End Function
Private Function PathLength(ShortPath$) As Integer
PathLength = Len(LetterToUNC(Left$(ShortPath$, 2)) _
& Right$(ShortPath$, Len(ShortPath$) - 2))
End Function
[/tt]
Get the length of the path....
[tt]
MyPath$ = "I:\Vorpal Shield\FileInfo"
MsgBox "Length of path to " _
& MyPath$ & " = " & PathLength(MyPath$)
[/tt]
Here's the easy way....
Place a Drive List Box on a form and check the items against the first two letters of the test path.
[tt]
MyPath$ = "I:\Vorpal Shield\FileInfo"
For Re = 1 To Drive1.ListCount - 1
TmpPath$ = Drive1.List(Re)
If UCase(Left(TmpPath$, 2)) = _
UCase(Left$(MyPath$, 2)) Then
If InStr(TmpPath$, "\"

> 0 Then 'Mapped Drive?
MyTmpPath$ = Mid$(TmpPath$, InStr( _
TmpPath$, "["

+ 1, _
Len( _
TmpPath$) - InStr(TmpPath$, "[" _
) _
)
LengthOfPath = Len(MyTmpPath$) + Len(MyPath$) - 3
Else
LengthOfPath = Len(MyPath$)
End If
Exit For
End If
Next
[/tt]
Both ways should produce similar results.
[tt]
MsgBox PathLength(MyPath$) & "=" & LengthOfPath
[/tt]
'====================================================================