[VB] Transformer un pathname windows en pathname DOS (noms courts) ?

Transformer un pathname windows en pathname DOS (noms courts) ? [VB] - Programmation

Marsh Posté le 20-04-2001 à 18:49:08    

Comment transformer un pathname windows ( avec noms longs ) en pathname DOS (noms courts) avec les ~1 ?
Merci! ;)

Reply

Marsh Posté le 20-04-2001 à 18:49:08   

Reply

Marsh Posté le 21-04-2001 à 23:52:51    

Il me semble qu'il y a une API pour ca ...
ha ca y est, j'ai trouvé : GetShortFileName ...
 
voila : (dans un module) :
 
Private Declare Function GetShortPathName Lib "kernel32" _
   Alias "GetShortPathNameA" (ByVal lpszLongPath As String, _
   ByVal lpszShortPath As String, ByVal cchBuffer As Long) _
   As Long
 
Public Function GetShortFileName(ByVal FullPath As String) _
  As String
 
'PURPOSE: Returns DOS File Name (8.3 Format) Give
'FullPath for long file name
 
'PARAMETERS: FullPath: Full Path of Original File
 
'RETURNS: 8.3 FileName, or "" if FullPath doesn't
'         exist or file fails for other reasons
 
'EXAMPLE:  
'Debug.Print _
'  GetShortFileName("C:\My Documents\My Very Long File Name.doc" )
 
'If file exists, will display C:\MYDOCU~1\MYVERY~1.DOC
'in the debug window
 
Dim lAns As Long
Dim sAns As String
Dim iLen As Integer
   
On Error Resume Next
 
'this function doesn't work if the file doesn't exist
If Dir(FullPath) = "" Then Exit Function
 
sAns = Space(255)
lAns = GetShortPathName(FullPath, sAns, 255)
GetShortFileName = Left(sAns, lAns)
     
End Function
 
 
et donc NomCourt = GetShortFileName(NomLong)


---------------
FAQ fclc++ - FAQ C++ - C++ FAQ Lite
Reply

Marsh Posté le 23-04-2001 à 17:38:59    

Merci!  
J'essaye ca demain! ;)

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed