1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| -----------------------------------------------------------------------
Private Declare Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA" (ByVal lpszLocaName As String, _
ByVal lpszRemoteName As String, cbRemoteName As Long) As Long
-----------------------------------------------------------------------
Public Function GetUNCPath(ByVal PathName As String) As String
Const MAX_UNC_LENGTH As Integer = 512
Dim strUNCPath As String
Dim strTempUNCName As String
Dim lngReturnErrorCode As Long
strTempUNCName = String(MAX_UNC_LENGTH, 0)
lngReturnErrorCode = WNetGetConnection(Left(PathName, 2), strTempUNCName, MAX_UNC_LENGTH)
If lngReturnErrorCode = 0 Then
strTempUNCName = Trim(Left(strTempUNCName, InStr(strTempUNCName, vbNullChar) - 1))
strUNCPath = strTempUNCName & Mid(PathName, 3)
End If
GetUNCPath = strUNCPath
End Function |
Partager