Solved

Delphi Alias

Posted on 1999-01-25
7
1,138 Views
Last Modified: 2010-08-05
I need modify delphi alias from source code, please help me.
0
Comment
Question by:GERSOFT
[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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Industry Leaders: 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!

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month6 days, 1 hour left to enroll

627 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