was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

28 Visitors Online


 
...Infos von Aliasen ermitteln?
Autor: Dan Butler
[ Tip ausdrucken ]  

Tip Bewertung (2):  
     


{
  Here's a demo to demonstrate how to get info about aliases in Delphi.
  First, create a new project with a listbox and 3 labels (called ListBox1,
  Label1, Label2, and Label3).  Then add an OnCreate event handler for the form
  with this code in it:
}

{
  Das folgende Beispiel zeigt, wie man Infos von Aliasen ermitteln kann.
  Erstelle ein neues Projekt und platziere eine Listbox und 3 Labels (ListBox1,
  Label1, Label2, and Label3) auf der Form. Dann Schreibe im OnCreate Ereignis
  folgenden Code:
}

procedure TForm1.FormCreate(Sender: TObject);
begin
  
{
    GetAliasNames Populates a string list with the names of persistent
    Borland Database Engine (BDE) aliases.

    GetAliasNames fügt die Namen der dauerhaften
    Aliase der Borland Database Engine (BDE) in eine Listbox.
  }
  
Session.GetAliasNames(ListBox1.Items);
end;

{ Now add an OnClick event for the Listbox: }
{ Schreibe nun im OnClick Ereignis der Listbox diesen Code }

procedure TForm1.ListBox1Click(Sender: TObject);
var
  
tStr: array[0..100] of char;
  Desc: DBDesc;
{
 The DBDesc structure describes a database, using the following fields:

 szName    DBINAME  Specifies the database alias name.
 szText    DBINAME  Descriptive text.
 szPhyName  DBIPATH  Specifies the physical name/path.
 szDbType   DBINAME  Specifies the database type.
}
begin
  if 
ListBox1.Items.Count = 0 then
    
exit;
  StrPLCopy(tStr, ListBox1.Items.Strings[ListBox1.ItemIndex], High(tStr));
  DbiGetDatabaseDesc(tStr, @Desc);
  with Desc do
  begin
    
Label1.Caption := StrPas(Desc.szName);
    Label2.Caption := StrPas(Desc.szPhyName);
    Label3.Caption := StrPas(Desc.szDbType);
    Label4.Caption := StrPas(Desc.szText);
  end;
end;

// Now add the following to the 'uses' clause at the top of the unit:
// Folgende Units müssen noch in die Uses-Klausel aufgenommen werden:

uses
  
{...,}DB, DBTables, DBITypes, DBIProcs;
  

{********************************************************************}

{
  This Examples is just another approach to get infos about aliases
  Using 2 component (TListBox) and only use 1 uses clause (dbTables)
}

uses
  
{...}, DBTables;

type
  
TForm1 = class(TForm)
    ListBox1: TListBox;
    ListBox2: TListBox;

{..}

implementation

{..}

procedure TForm1.FormCreate(Sender: TObject);
begin
  
{Get Alias Names}
  
Session.GetAliasNames(ListBox1.Items);
end;

procedure TForm1.ListBox1Click(Sender: TObject);
begin
  
ListBox2.Items.Clear;
  if ListBox1.Items.Count = 0 then
    
Exit;
  {Get Alias Driver Names, like Standard, MsAccess, etc}
  
ListBox2.Items.Add('DRIVER=' + Session.GetAliasDriverName(ListBox1.Items.Strings
      [ListBox1.ItemIndex]));
  {Get Alias Parameters and add it parameters into listbox2}
  
Session.GetAliasParams(ListBox1.Items.Strings[ListBox1.ItemIndex], ListBox2.Items);
end;

end.

 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners