Option Explicit
Private Declare PtrSafe Function DavGetUNCFromHTTPPath Lib "Netapi32.dll" (ByVal Url As LongPtr, ByVal UncPath As LongPtr, lpSize As Long) As Long
#Else
Private Declare Function DavGetUNCFromHTTPPath Lib "Netapi32.dll" (ByVal Url As Long, ByVal UncPath As Long, lpSize As Long) As Long
Public Function getUNCPath(pPath As String) As String
Dim lPath As String
Dim lUncPath As String
Dim lSize As Long
lSize = 260
lPath = pPath & vbNullChar
lUncPath = Space(lSize)
If DavGetUNCFromHTTPPath(StrPtr(lPath), StrPtr(lUncPath), lSize) = 0 Then
getUNCPath = Left(lUncPath, lSize - 1)
If Right(pPath, 1) = "/" Or Right(pPath, 1) = "\" Then
getUNCPath = getUNCPath & "\"
End If
Else
getUNCPath = pPath
End If
End Function