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

x
?
Solved

Delphi Alias

Posted on 1999-01-25
7
Medium Priority
?
1,153 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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 150 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: 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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Screencast - Getting to Know the Pipeline

824 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