Le chemin cours (c:\progra~1\)
converti un chemin long en chemin cours (dos)
- Code : Tout sélectionner
Public Function GetShortPath_API(wPath As String) As String
%REM
'variableAPI pour la fonction GetShortPath_API
Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (Byval lpszLongPath As String, Byval lpszShortPath As String, Byval lBuffer As Long) As Long
%END REM
'déclaration Variable
Dim I As Long
Dim Path As String
On Error Goto ErreurGetShortPath_API
GetShortPath_API = ""
If Trim(wPath) = "" Then
Exit Function
End If
Path = String$(165, 0)
i = GetShortPathName(wPath, Path, 164)
GetShortPath_API = Left$(Path, i)
Path = ""
Exit Function
ErreurGetShortPath_API:
Msgbox "("+Cstr(Getthreadinfo(1))+")"+Chr(10)+"Erreur " + Str(Err) + " : "+Chr(10) + Cstr(Error)+"."+Chr(10)+"Ligne N° "+Cstr(Erl),16," ERREUR !"
GetShortPath_API = ""
Exit Function
End Function