Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- '====================================================================
- Public Function GetFixedFileName(ByVal FileName As BStr) As BStr
- Dim hFile As API_HANDLE
- Dim Buff As BStr
- Dim RC As Long
- hFile = CreateFileByNumW(FileName, GENERIC_WRITE, 0, ByVal 0&, CREATE_ALWAYS, 0, 0)
- If hFile = INVALID_HANDLE_VALUE Then
- GetFixedFileName = FileName
- Exit Function
- End If
- CloseHandle hFile
- RC = GetShortPathNameW(FileName, "", 0)
- If RC = 0 Then
- GetFixedFileName = FileName
- Exit Function
- End If
- RC = RC + 2
- Buff = String(RC + 10, 0)
- RC = GetShortPathNameW(FileName, Buff, RC)
- If RC = 0 Then
- GetFixedFileName = FileName
- Exit Function
- End If
- GetFixedFileName = Left(Buff, RC)
- End Function
Add Comment
Please, Sign In to add comment