Die nachfolgende Klasse ermittelt den UNC Namen eins gemounteten Netzlaufwerkes.
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 strTmp As String = New String(" ", 260)
Dim intLen As Integer = 260
Dim intCnt As Integer = 0
intRet = WNetGetConnection(strDriveLetter.Substring(0, 1) & ":", strTmp, intLen)
Do Until intCnt = (intLen - 1) Or strTmp.Substring(intCnt + 1, 1) = " "
strRet &= strTmp.Substring(intCnt, 1)
intCnt += 1
Loop
Return strRet
End Function
End Class
1 Kommentare zum Snippet