...lange Dateinamen in kurze umwandeln?
Autor: Simon Grossenbacher
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
// handle errors...
end;
SetLength(sShortName, nShortNameLen);
Result := sShortName;
end;
// Example:
procedure TForm1.Button1Click(Sender: TObject);
begin
Caption := GetShortName('C:\Program Files\Delphi6\Lib\test.cnt');
// --> C:\PROGRA~1\Delphi6\Lib\test.cnt
end;
printed from
www.swissdelphicenter.ch
developers knowledge base