Solved

Delphi Alias

Posted on 1999-01-25
7
1,130 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

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 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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

809 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