Category: Files
Title: Convert long filenames in short filenames
Date added: 15.03.2006
Hits: 1573
{
Usage:
GetShortName('C:\Program Files\test.txt');
which returns "C:\PROGRA~1\test.txt"
}
uses
Windows, SysUtils;
function GetShortName(sLongName: string): string;
var
sShortName: string;
nShortNameLen: Integer;
begin
SetLength(sShortName, MAX_PATH);
nShortNameLen := GetShortPathName(PChar(sLongName), PChar(sShortName), MAX_PATH - 1);
if (0 = nShortNameLen)
then
begin
showmessage('Error!');
end;
SetLength(sShortName, nShortNameLen);
Result := sShortName;
end;