GARANTIR DESCONTO

Fórum Como Abreviar nome de Diretorio (com o ~1) , tipo o MS-DOS ? #163534

30/05/2003

0

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

Responder

Posts

30/05/2003

Adilsond

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;



Responder

Gostei + 0

31/05/2003

Conteme2

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


Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar