README.md
December 5, 2022 ยท View on GitHub
Description
This code enables you to convert a long file location and filename to a short file location and filename. Example: C:\Program Files\Test.txt
will become C:\Progra~1\Test.txt
More Info
| Submitted On | |
| By | CovertLoop |
| Level | Beginner |
| User Rating | 4.3 (17 globes from 4 users) |
| Compatibility | VB 4.0 (16-bit), VB 4.0 (32-bit), VB 5.0, VB 6.0 |
| Category | Coding Standards |
| World | Visual Basic |
| Archive File |
API Declarations
ADD TO A MODULE
Declare Function GetShortPathName Lib "kernel32" Alias _
"GetShortPathNameA" (ByVal lpszLongPath As String, ByVal _
lpszShortPath As String, ByVal cchBuffer As Long) As Long
Source Code
Add The Declarations Above To A Module. Then put this whenever you want to perform the conversion:
Dim sFile As String, sShortFile As String * 67
Dim lRet As Long
sFile = "C:\Program Files\Test.txt" 'Long File Location/Name
lRet = GetShortPathName(sFile, sShortFile, Len(sShortFile))
sFile = Left(sShortFile, lRet)
Text1.Text = sFile