Solved

Creating a permanent Alias in IDAPI32.CFG file

Posted on 2007-11-15
3
546 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

828 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