How can I modify aliases programmatically ? | |||
| |||
The code below modifies an alias called test to point to directory c:dirname. This uses the session variable and requires unit DBTables. (Delphi Ref) Session is responsible for maintaining all of the database components used by an application. It is created automatically as part of an application's initialization and destroyed as part of the application's termination. The Session variable must remain active at all times; it can not be destroyed and recreated. unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, DBTables; type TForm1 = class(TForm) Button1: TButton; Database1: TDatabase; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.Button1Click(Sender: TObject); var List: TStringList; begin List := TStringList.Create; //A stringlist with the new value List.Add('path=c:dirname'); //the dir you want List.Add('driver name=paradox'); Session.ModifyAlias('test', List); //this method, make the changes Session.SaveConfigFile; // This method, save the changes end; end. Tags: Alias Delphi TDatabase aliases | |||
| |||
| |||
Login for comment |
OTHER POSTS IN THE SAME CATEGORY How To Change The System Time |