Die nachfolgende Klasse ermittelt den UNC Namen eins gemounteten Netzlaufwerkes. (Ddanke an Volker für die Deklaration)
Public Class clsUnc
Private Declare Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA" (ByVal lpszLocalName As String, ByVal lpszRemoteName As String, ByRef cbRemoteName As Integer) As Integer
Friend Shared Function fnGetUncPath(ByVal strDriveLetter As String) As String
Dim intRet As Integer
Dim strRet As String = ""
Dim Length As Integer = 260
Dim strTemp As String = New String(" ", Length)
intRet = WNetGetConnection(strDriveLetter.Substring(0, 1) & ":", strTemp, Length)
strRet = strTemp.Substring(0, strTemp.IndexOf(Chr(0)))
Return strRet
End Function
End Class
1 Kommentare zum Snippet