Solved

Delphi Alias

Posted on 1999-01-25
7
1,128 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
Comment Utility
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
Comment Utility
What is delphi alias?
0
 
LVL 2

Expert Comment

by:SupWang
Comment Utility
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:GERSOFT
Comment Utility
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
Comment Utility
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
Comment Utility
delete alias and create same alias with new path? no. I need MODIFY alias path.
0
 

Accepted Solution

by:
jdev011599 earned 50 total points
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now