Board index » delphi » Change/Create Alias at Runtime

Change/Create Alias at Runtime

Is there a way to change the directory the Alias points to at runtime?

Thanks, James Armstrong
jam...@awod.com

 

Re:Change/Create Alias at Runtime


Quote
Hime wrote:

> Is there a way to change the directory the Alias points to at runtime?

> Thanks, James Armstrong
> jam...@awod.com

James:

You might want to use a Database component - set the Alias property to
the existing alias, and override the PATH parameter in the Params
property. Use the new alias defined by the Database component in your
code. Right-click the Database component and use the Database Editor to
simplify this process.

-Cary

Re:Change/Create Alias at Runtime


You can do it through a direct call to the BDE. Refer to my other message.

--

Mark P
-----------
http://www.ozemail.com.au/~pritchma

Hime <h...@please.help> wrote in article
<MPG.d28c4ee2dd98b2a989...@207.126.101.79>...

Quote
> Is there a way to change the directory the Alias points to at runtime?

> Thanks, James Armstrong
> jam...@awod.com

Re:Change/Create Alias at Runtime


Quote
None wrote:

> Hime wrote:

> > Is there a way to change the directory the Alias points to at runtime?

> > Thanks, James Armstrong
> > jam...@awod.com

> James:

> You might want to use a Database component - set the Alias property to
> the existing alias, and override the PATH parameter in the Params
> property. Use the new alias defined by the Database component in your
> code. Right-click the Database component and use the Database Editor to
> simplify this process.

> -Cary

this two routine :
1st check if alias exist;
2nt add the alias ( uses dbiprocs);

function isExist(var aliasstr:string):boolean;
var
 aliaslist:tstringlist;
 i:integer;
 isexit:boolean;
begin
aliaslist:=tstringlist.create;
session.getaliasnames(aliaslist);{read aliases from idapi.cfg}
isexit:=false;
for i:=0 to aliaslist.count-1 do begin {check if alias exist}
  isexit:=UPPERCASE(aliasstr)=UPPERCASE(aliaslist[i]);
  if isexit then begin
   result:=true;
   exit;
   end;
  end;
result:=isexit;
aliaslist.free;
end;

procedure doaddalias(AliasStr,tbtype,dbpath:string);
begin
  dbpath:='path:'+dbpath;{The path you want to modify here}
  Check(DbiAddAlias(Nil, PChar(AliasStr),stringaspchar(tbtype)
  , PChar(dbpath), True));
end;

see the BDEAPI for more detail;FUNCTION DbiOpenCfgInfoList;

Alfred Yang /Taiwan

Other Threads