Extracting the short path name (Win3.1 style)
   


This function, when passed a long path name, will convert it to a short Win3.1 style path name. For example: ExtractShortPathName('C:\This is a directory\This is a file.txt') will return 'C:\Thisis~1\Thisis~1.txt'. To extract the long path name, see ExtractLongPathName().

function ExtractShortPathName(const FileName: string): string;
{ func to shorten the long path name to look like Win 3.1 naming conventions. }
{ If file doesn't exist, func will return an empty string. }

var
  Buffer: array[0..MAX_PATH] of Char;
begin
  SetString(Result, Buffer, GetShortPathName(PChar(FileName), Buffer, SizeOf(Buffer)));
end;



Blue Orb Software

[email protected]