sábado, 6 de junho de 2009

Convertendo nomes longos para nomes curtos

{Para converter um nome longo de arquivo para um nome curto (e vice-versa), use as seguintes funções (a primeira retorna um nome curto e a segunda um nome longo): }
function GetShortFileName (const Arquivo : String) : String;
var
aTmp : array [0..255] of char;
begin
if GetShortPathName (PChar (Arquivo), aTmp, sizeof (aTmp) - 1) = 0 then
Result := Arquivo
else
Result := StrPas (aTmp);
end;

function GetLongFileName (const Arquivo : String) : String;
var
aInfo : TSHFileInfo;
begin
if SHGetFileInfo (PChar(Arquivo), 0, aInfo, sizeof (aInfo), SHGFI_DISPLAYNAME) <>0 then
Result := String (aInfo.szDisplayName)
else
Result := Arquivo;
end;

Nenhum comentário:

Postar um comentário