//程序中自定义BDE变量
procedure GiveAlias(AliasName: string; DriverPath: string);
var
ListTxt: TStringList;
begin
Session.ConfigMode := cmAll;
//自动判断变量是否存在,不存在就建立一个
if Session.IsAlias(AliasName) then
begin
ListTxt := TStringList.Create;
Session.GetAliasParams(AliasName, ListTxt);
//看变量中的路径是否正确,如果不正确就修改
if ListTxt.Values['Path'] <> DriverPath then
begin
ListTxt.Values['Path'] := DriverPath;
Session.ModifyAlias(AliasName, ListTxt);
Session.SaveConfigFile;
end;
ListTxt.Free;
end
else
begin
Session.AddStandardAlias(AliasName, DriverPath, 'PARADOX');
Session.SaveConfigFile;
end;
end;
//判断数据库是否存在
function GiveDataBase(AliasName: string; DatabaseName: string): Boolean;
var
DbList: TStringList;
begin
//判断数据库是否存在
DbList := TStringList.Create;
Session.GetTableNames(AliasName, '', False, False, DbList);
if (DbList.IndexOf(DatabaseName) = -1) then
result := False
else
result := True;
DbList.Free;
end;
这两个函数是我程序中使用的,绝对好用!