Caminho do Alias

Delphi

12/03/2004

Por favor. Gostaria de Obter o caminho de meu Alias Na aplicacao.
desde ja agradeco.


Uso Paradox sem tdatabase


Aguiarle

Aguiarle

Curtidas 0

Respostas

Adriano Santos

Adriano Santos

12/03/2004

function PathAlias(sAlias : String) : String;
{Retorna o Path do Alias em uso}
var
  AliasNameList : TStringList;
  sDir          : String;
begin
  //Obter o nome dos aliases
  AliasNameList := TStringList.Create;
  try
    Session.GetAliasParams(sAlias, AliasNameList);
    sDir := AliasNameList.Strings[0];
    //Se não for achado a palavra PATH então não é do tipo Paradox ou Dbase
    //fica seu critério como você quer todo o tipo é só tirar este [ if pos()]}
    if Pos(´PATH´,sdir) <> 0 then // Paradox
    begin
      System.Delete(sdir,1,5)
    end
    else
    if Pos(´DATABASE NAME´,sdir) <> 0 then // Access
    begin
      System.Delete(sdir,1,14)
    end
    else
    if Pos(´SERVER NAME´, sDir ) <> 0 then // InterBase
    begin
      System.Delete(sDir,1,12)
    end
    else
    begin
      sdir := ´\´;
    end;
  finally
    begin
      AliasNameList.Free;
    end;
  end;
  Result := sDir;
end;


use assim

Edit1.Text := PathAlias(´MeuNomeAlias´);



GOSTEI 0
Aguiarle

Aguiarle

12/03/2004

Obrigado, deu certinho
8)


GOSTEI 0
Aroldo Zanela

Aroldo Zanela

12/03/2004

Outro exemplo:

function GetPath(AliasName: string): TFileName;
var ParamList: TStringList;
begin
  ParamList := TStringList.Create;
  with Session do
  try
    GetAliasParams(AliasName,ParamList);
    Result := UpperCase(ParamList.Values[´PATH´])+´\´;
  finally
    Paramlist.Free;
  end;
end;


Usando:

  ShowMessage(GetPath(´ALIAS´));



GOSTEI 0
POSTAR