VB-Tec.de Visual Basic - Technik, FAQ, Tricks, BeispieleLange Pfade in (kurze) DOS-Pfade konvertieren |
Folgende API-Routine (und Wrapper-Funktion) konvertiert einen langen (Win32-)Dateipfad in einen kurzen, DOS-kompatiblen Pfad:
'API-Deklaration:
Private Declare Function GetShortPathNameA Lib "kernel32" ( _
ByVal lpszLongPath As String, _
ByVal lpszShortPath As String, _
ByVal cchBuffer As Long) As Long
'Funktion:
Public Function ShortPath(ByRef Path As String) As String
Dim n As Long
ShortPath = Space$(256)
n = GetShortPathNameA(Path, ShortPath, 255)
ShortPath = Left$(ShortPath, n)
End Function
Übrigens: In "Langen Dateinamen bestimmen" ist die Umkehrfunktion zu finden.
© Jost Schwider, 30.04.2000-30.04.2000 - http://vb-tec.de/dospfade.htm