How can I modify aliases programmatically ?

CK CK 3788 
Created at
Updated at  
1,319 0 0

Take a look at TDatabase. You can set the Alias property to the physical path at runtime. InstallShield Express, which ships with D2 and D3 (and greater)lets you define new aliases with paths relative to the directory where the user installs the program.

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 TDatabase aliases Facebook X
Comments 0
  1. How To Change The System Time
    1,267
  2. How To Get The Windows OS Version
    623
  3. How To Change The Desktop Wallpaper
    2,177
  4. How To Get The Windows Language
    1,161
  5. How To Make A Gradient Filled Form
    847
  6. How can I hide the caption bar on a form?
    1,404
  7. How To Send An E-mail By Code
    1,125
  8. How To Open Url In Default Webbrowser
    466
  9. How To Check If A Soundcard Is Installed
    1,571
  10. How To Change Screen Resolution
    2,091
  11. How To Force The Correct Decimal Separator
    1,789
  12. How To Register Own File Types
    1,200
  13. How To Get Volume Name
    416
  14. How To Get Windows And System Directory
    2,743
  15. Get The Drive Type
    508
  16. Setting TQuery SQL Statement
    12,165
Recently updated
  1. Google OAuth Token Expiration: Causes and Solutions
    31
  2. Why 100% SEO Guarantees Better User Engagement and How to Achieve It in Your Service
    57
  3. Why SPF and DKIM Are Essential for Linux Email Servers?
    51
  4. How do I create animated background for Google Meet?
    23,255
  5. MaxMind GeoLite2 vs. DB-IP Lite vs. ip-api.com: Choosing the Right Free IP Geolocation Solution
    273
  6. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    104
  7. How Rogue Web Scrapers Are Stealing My Content and Destroying My Server
    170
  8. Array of arguments passed to script in PHP
    99
  9. Invalid Auction Storms in Ad Tech
    108
  10. Building MRC-Compliant Instrumentation in Ad Tech: Implementation Steps and Key Challenges
    209
  11. The Two Clocks of Ad Server Architecture
    78
  12. Frequency Cap Architecture Overview
    527
  13. Collecting Proof-of-Play from 100,000 Screens
    153
  14. Vector Search in Relational Databases (RDBs): Trends & Usage Environments
    303
  15. What is RedisVL?
    117
  16. Designing a Skill Registry Architecture: Minimize Token Usage and Maximize AI Performance
    247
  17. TPU & GPU Cluster Management Tools
    258
  18. The Concept of Scaffolding in AI Agents
    245
  19. Beyond Static Pipelines: Architecting LLM Multi-Agent Systems for Autonomous Workflow Orchestration
    598
  20. AI-DLC vs. AI-SDLC: Model-Centric vs. System-Centric AI Development
    269
  21. Fine-Tuning Open-Weight LLMs: Training, Licensing, and Deploying Custom Models with Ollama
    355
  22. Inside the Next-Generation Streaming Architecture: Ultra-Low Latency, SGAI, and AI Codecs
    207
  23. Machine Learning: Training vs. Ranking
    230
  24. The Continuous Learning Machine: Designing a Loop That Actually Turns
    229
  25. The Next-Gen Low-Latency Standards: LL-HLS & MoQ
    204
  26. Designing a Data Curation System Around a Vector Database
    230
  27. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    263
  28. The New Ad Stack Behind Live Sports Streaming: Inside SGAI, EABN, and the Standards Race to Fix Live Monetization
    674
  29. Designing MLOps Architectures to Handle Seasonal Data Drift in EV Fleet Models
    201
  30. From 15 to 40+ FPS: Accelerating PyTorch Object Detection on Automotive ECUs
    233