Dichiarare la seguente funzione API In un modulo Bas
Public Declare Function GetShortPathName Lib "KERNEL32" Alias "GetShortPathNameA" _ (ByVal lpszLongPath As String, ByVal lpszShortPath As String, _ ByVal cchBuffer As Long) As Long E richiamarla con questa funzione: Public Function GetShortFileName(ByVal FileName As String) As String Dim rc As Long Dim ShortPath As String Const PATH_LEN& = 164 ShortPath = String$(PATH_LEN + 1, 0) rc = GetShortPathName(FileName, ShortPath, PATH_LEN) GetShortFileName = Left$(ShortPath, rc) End Function oppure ___________________________________________________________________ Dove FileName e' il path o il nome del file da convertire e ritorna un nome DOS compatibile, pertanto si dichiarera': Dim Lblshort, LongName As String Lblshort = GetShortFileName(LongName) Declare Function GetShortPathName Lib "KERNEL32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long Convertire un nome lungo di file In formato DOS ------------------------------------------------------------------------ La funzione sottostante converte i nomi di file o Do path lunghi In modalita' DOS (non piu' di 8 caratteri) 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 FileName As String) As String Dim rc As Long Dim ShortPath As String Const PATH_LEN& = 164 ShortPath = String$(PATH_LEN + 1, 0) rc = GetShortPathName(FileName, ShortPath, PATH_LEN) GetShortFileName = Left$(ShortPath, rc) End Function Dove FileName e' il path o il nome del file da convertire e ritorna un nome DOS compatibile, pertanto si dichiarera': Dim Lblshort, LongName As String Lblshort = GetShortFileName(LongName) |