Como Abreviar nome de Diretorio (com o ~1) , tipo o MS-DOS ?

Delphi

30/05/2003

Bem , estou precisando que uma variavel receba uma estrutura de Diretorios, mas gostaria que vie-se no formato MS-DOS, exemplo:

c:\docume~1\asdfa~1\blabla~1

, o que eu consigo é pega-la no formato inteiro por exemplo:

c:\documents and configurats\asdfasdfsadf\blablablabla


gostaria que fosse abreviado , como no 1º exemplo, alguem pode ajudar??? ficarei grato !!!


Conteme2

Conteme2

Curtidas 0

Respostas

Adilsond

Adilsond

30/05/2003

Extraído do link: http://www.blueorbsoft.com/CodeTips/DelphiCodeTips1.html

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

function ExtractLongPathName(const PathName: string): string;
{ func to expand a Win3.1 style path name to a 32-bit Windows naming convention. }
{ If file doesn´t exist, func will return an empty string.                       }
var
  LastSlash, PathPtr: PChar;

  function ExtractLongFileName(const FileName: string): string;
  var
    Info: TSHFileInfo;
  begin
    if SHGetFileInfo(PChar(FileName), 0, Info, Sizeof(Info), SHGFI_DISPLAYNAME) <> 0 then
      Result := string(Info.szDisplayName)
    else 
      Result := FileName;
  end;

begin
  Result := ´´;
  PathPtr := PChar(PathName);
  LastSlash := StrRScan(PathPtr, ´\´);
  while LastSlash <> nil do
    begin
      Result := ´\´ + ExtractLongFileName(PathPtr) + Result;
      if LastSlash <> nil then
        begin
          LastSlash^ := #0;
          LastSlash := StrRScan(PathPtr, ´\´);
        end;
    end; 
  Result := PathPtr + Result;
end;



GOSTEI 0
Conteme2

Conteme2

30/05/2003

Valeu a intensão, mas o que eu gostaria mesmo era ao contrario no Formato C:\ASDFAS~1\SDFAS~1 !!!
entendeu ???


GOSTEI 0
POSTAR