Public Declare Function WNetGetConnection Lib "mpr.dll" _
Alias "WNetGetConnectionA" _
(ByVal lpszLocalName As String, _
ByVal lpszRemoteName As String, _
cbRemoteName As Long) As Long
Private Declare Function PathIsUNC Lib "shlwapi" _
Alias "PathIsUNCA" _
(ByVal pszPath As String) As Long
Function FileUNC(ByVal strPath As String) As String
Dim strNetPath As String
strNetPath = String(255, Chr(0))
WNetGetConnection Left(strPath, 2), strNetPath, 255
If PathIsUNC(strNetPath) Then
FileUNC = Left(strNetPath, InStr(1, strNetPath, Chr(0)) - 1) & _
Right(strPath, Len(strPath) - 2)
Else
FileUNC = strPath
End If
End Function