Re:Looking for a component that returns Path of the BDE alias
Try the following.
-----------------------------------------------------
Here are three ways to get the path associated with an alias. No1 is for
permanent BDE aliases only. No2 works on BDE and local aliases and No3 works
with BDE and local aliases as well as with tables with a hardcoded path,
using DBI calls.
function GetDBPath1(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;
function GetDBPath2(AliasName: string): TFileName;
var ParamList: TStringList;
i: integer;
begin
ParamList := TStringList.Create;
with Session do
try try
GetAliasParams(AliasName,ParamList);
except
for i:=0 to pred(DatabaseCount) do
if (Databases[i].DatabaseName = AliasName) then
ParamList.Assign(Databases[i].Params);
end;
Result := UpperCase(ParamList.Values['PATH'])+'\';
finally
Paramlist.Free;
end;
end;
function GetDBPath3(ATable: TTable): TFileName;
var TblProps: CURProps;
pTblName, pFullName: DBITblName;
begin
with ATable do
begin
AnsiToNative(Locale, TableName, pTblName, 255);
Check(DBIGetCursorProps(Handle, TblProps));
Check(DBIFormFullName(DBHandle,
pTblName,
TblProps.szTableType,
pFullName));
Result := ExtractFilePath(StrPas(pFullName));
end;
end;
--
Bill