Solved

Creating a permanent Alias in IDAPI32.CFG file

Posted on 2007-11-15
3
541 Views
Last Modified: 2010-04-21
Hi Experts,
I'm trying to add a new Alias to the IDAPI32.CFG file, which I want to stay permanently. i.e.

  Check(DbiAddAlias(nil, PChar(AliasName), nil, PChar(AliasPath), True));

The problem is the new Alias only remains in the IDAPI32.CFG file for the current session.  On closing the session the new Alias is deleted!

Many thanks
0
Comment
Question by:Vector7
3 Comments
 
LVL 13

Accepted Solution

by:
rfwoolf earned 500 total points
ID: 20293958
This is how I do it.

First make sure you have added DBTables to your unit's uses clause.

Then in a procedure such as a OnButtonClick:

Let me know if it works :)


var

sNewAlias, sDataDir :string;

mystringlist : TStringlist;

daindex : integer;

begin

mystringlist := TStringlist.Create;
 

//Assign name of the Alias to a string

sNewAlias := 'MyNewAlias';

//Assign name of the Alias's data directory to a string

sDataDir := Edit1.text;

//In the current session, grab the names of all the aliases and store them in myStringList

session.GetAliasNames(mystringlist);

//Get the index of your desired new alias - if it already exists you'll get a number > -1, else you'll get -1

daIndex := mystringlist.IndexOf('MyNewAlias);
 

//If the Alias already exists, delete it

if daIndex <> -1 then

Session.DeleteAlias('MyNewAlias');
 

//Now add the new alias, note the last section will create a 'PARADOX' database alias.

Session.AddStandardAlias(sNewAlias, sDataDir, 'PARADOX') ;
 

//And here's your magic line: SAVE THE CFG FILE!

Session.SaveConfigFile;
 

end;

Open in new window

0
 
LVL 10

Expert Comment

by:dinilud
ID: 20296453
 procedure ChangeAliasDirPARADOX(Alias, Dir: String);
  begin
    if DirectoryExists(Dir) then
    begin
      if Session.IsAlias(Alias) then  Session.DeleteAlias(Alias);
      Session.AddStandardAlias(Alias, Dir, 'PARADOX');
      Session.SaveConfigFile;
    end;
  end;
0
 

Author Closing Comment

by:Vector7
ID: 31409439
Works well. Many thanks.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now