Solved

Delphi Alias

Posted on 1999-01-25
7
1,133 Views
Last Modified: 2010-08-05
I need modify delphi alias from source code, please help me.
0
Comment
Question by:GERSOFT
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 2

Expert Comment

by:SupWang
ID: 1363304
Hi, GERSOFT

You need to use the BDE API function AddAlias.

function DbiAddAlias (hCfg: hDBICfg; pszAliasName: PChar; pszDriverType: PChar; pszParams: PChar; bPersist: Bool): DBIResult stdcall;

This is a nasty looking function call, so I will try to give an example which makes it easier to understand. For further information, you need to look in the BDE API help file and search for the AddAlias function.


1. Add the following units to your uses clause:

uses DB, DbiProcs;

2. Add a procedure like this:

procedure AddMyAlias(AliasName, AliasPath: String);
begin  
  // Check takes a DbiResult and determines if there is an error
  Check(dbiInit(Nil));  // Require in order to use DbiAddAlias
  Check(DbiAddAlias(Nil, PChar(AliasName), Nil,
        PChar(AliasPath), True));
end;

3. Call the function like this:

AddMyAlias('TestAlias','PATH:C:\MYPATH');

Regards, SupWang

0
 
LVL 20

Expert Comment

by:Madshi
ID: 1363305
What is delphi alias?
0
 
LVL 2

Expert Comment

by:SupWang
ID: 1363306
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:GERSOFT
ID: 1363307
i need modify path from the alias by code:

   alias:=getcurrentdir+'\temp';
// save to new alias path
// procedures.....
   alias:=getcurrentdir+'\temp1';
// save to new alias path...

.

etc.
0
 

Expert Comment

by:jdev011599
ID: 1363308
Try using the TSession object. It has a method:
procedure AddAlias(const Name, Driver: string; List: TStrings);

I cut and pasted this example from some Delphi documentation:
//--------------------------------------------------------------------------------
var
  MyList: TStringList;
begin
  MyList := TStringList.Create;
  try
    with MyList do
    begin
      Add('SERVER NAME=IB_SERVER:/PATH/DATABASE.GDB');
      Add('USER NAME=MYNAME');
    end;
    Session1.AddAlias('NewIBAlias', 'INTRBASE', MyList);
  finally
    MyList.Free;
  end;
end;
//------------------------------------------------------------------------------------
Hope you can get what you need from this :)

best regards,
jdev
0
 

Author Comment

by:GERSOFT
ID: 1363309
delete alias and create same alias with new path? no. I need MODIFY alias path.
0
 

Accepted Solution

by:
jdev011599 earned 50 total points
ID: 1363310
Sorry,

TSession.ModifyAlias(Name: string; List: TStrings);

Name = Alias name
List = the Params for the alias

I suggest you use TSession.GetAliasParams
then use the TStrings.Values["param name"] property to set
the parameter you want
then pass the same TStrings back in ModifyAlias()

if you still need a hand I can
put together a src file for you.

Hope THIS is what you wanted

best regards,
jdev
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

679 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