Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Creating a permanent Alias in IDAPI32.CFG file

Posted on 2007-11-15
3
Medium Priority
?
552 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 2000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

916 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