Solved

Creating a permanent Alias in IDAPI32.CFG file

Posted on 2007-11-15
3
550 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Suggested Courses
Course of the Month5 days, 1 hour left to enroll

635 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