Wenn das so ist . . .
16.01.2009 10:47:00
Roland
musst Du die UNC-Laufwerksangabe erst "übersetzen". Ich nutze dazu folgende Routinen:
Private Function LogicalDrives() As Collection
Dim s As String * 128
Dim i As Long
GetLogicalDriveStringsA Len(s), s
i = InStr(s, vbNullChar & vbNullChar) ' Länge
Set LogicalDrives = New Collection
For i = 1 To i Step 4
LogicalDrives.Add Mid$(s, i, 2)
Next i
End Function
Private Function DrivePath(ByVal Path As String, _
Optional IgnoreErrors As Boolean = True) As String
Dim Drive As Variant
Dim UNC As String
If Right$(Path, 1) "\" Then Path = Path & "\"
For Each Drive In LogicalDrives()
UNC = UNCPath(Drive, True)
If InStr(1, Path, UNC, vbTextCompare) = 1 Then Exit For
Next Drive
If IsEmpty(Drive) Then
If IgnoreErrors Then
DrivePath = Path
Else
Err.Raise 5
End If
Else
DrivePath = Drive & Mid$(Path, Len(UNC))
End If
End Function
Private Function UNCPath(ByVal Path As String, _
Optional IgnoreErrors As Boolean = False) As String
Dim UNC As String * 512
If Len(Path) = 1 Then Path = Path & ":"
If Right$(Path, 1) "\" Then Path = Path & "\"
If WNetGetConnectionA(Left$(Path, 2), UNC, Len(UNC)) Then
' API-Routine gibt Fehler zurück:
If IgnoreErrors Then
UNCPath = Path
Else
Err.Raise 5
End If
Else
UNCPath = Left$(UNC, InStr(UNC, vbNullChar) - 1) _
& Mid$(Path, 3)
End If
End Function
Private Sub Test()
Dim Bild as String
Bild = DrivePath(\\172.24.0.10\Verzeichnis\) & ico.ico
End Sub
Kommen wir der Sache jetzt näher?
Gruß von
Roland Hochhäuser