![]() |
Tipp 0119
|
Dateinamen in 8+3 (DOS) konvertieren
|
 |
|
Autor/Einsender: Datum: |
|
Michael Werner 17.05.2006 |
|
Entwicklungsumgebung: |
|
VB.Net 2003 |
Framework: |
|
1.1 |
|
|
Auch heute noch ist es manchmal zwingend notwendig, einen Pfad zunächst in seine 8.3-Darstellung umzuwandeln, z.B. beim Einsatz des
Command-Prompt (Eingabeaufforderung). Der Tipp zeigt, wie man die Win32-API-Funktionen GetShortPathName und
GetLongPathName nutzen kann, um diese Umwandlungen von langem Dateinamen in den kurzen (8.3-Konvention) und umgekehrt vorzunehmen.
|
|
|
Private Declare Function GetShortPathName _
Lib "kernel32" Alias "GetShortPathNameA" ( _
ByVal strLongPath As String, _
ByVal strShortPath As String, _
ByVal intBufferLen As Integer _
) As Integer
Private Declare Function GetLongPathName _
Lib "kernel32" Alias "GetLongPathNameA" ( _
ByVal strShortPath As String, _
ByVal strLongPath As String, _
ByVal intBufferLen As Integer _
) As Integer
Public Function GetShortPathname(ByVal LongPathName As String) _
As String
Dim strShortName As String
Dim iLen As Integer
Try
iLen = GetShortPathname(LongPathName, strShortName, 0)
strShortName = Space(iLen - 1)
GetShortPathname(LongPathName, strShortName, iLen)
Return strShortName
Catch ex As Exception
End Try
End Function
Public Function GetLongPathname(ByVal ShortPathName As String) _
As String
Dim strLongName As String
Dim iLen As Integer
Try
iLen = GetLongPathname(ShortPathName, strLongName, 0)
strLongName = Space(iLen - 1)
GetLongPathname(ShortPathName, strLongName, iLen)
Return strLongName
Catch ex As Exception
End Try
End Function
|
|
|
|
|
Windows-Version |
98/SE |
 |
|
ME |
 |
|
NT |
 |
|
2000 |
 |
|
XP |
 |
|
Vista |
 |
|
Win
7 |
 |
|
|
|
Download (7,3 kB)
|
Downloads bisher: [ 436 ]
|
|
|