Kylix
Tips

NEW TIPS
Database (112)
Files (567)
Forms (583)
Graphic (520)
IDE (439)
Indy (410)
Internet / LAN (575)
IntraWeb (432)
Kylix (426)
Math (546)
Misc (565)
Multimedia (473)
Objects/
ActiveX (486)

OpenTools API (423)
Printing (428)
Strings (560)
System (705)
VCL (575)

Search Tip
Top15
Add new Tip

Forum

...get the ODBC datasource names?
Author: Grinder
[ Print tip ]    

Tip Rating (0):  
     



uses
  
Registry;

procedure TForm1.GetDataSourceNames(System: Boolean);
var
  
reg: TRegistry;
begin
  
ListBox1.Items.Clear;

  reg := TRegistry.Create;
  try
    if 
System then
      
reg.RootKey := HKEY_LOCAL_MACHINE
    else
      
reg.RootKey := HKEY_CURRENT_USER;

    if reg.OpenKey('\Software\ODBC\ODBC.INI\ODBC Data Sources', False) then
    begin
      
reg.GetValueNames(ListBox1.Items);
    end;

  finally
    
reg.CloseKey;
    FreeAndNil(reg);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  
//System DSNs
  
GetDataSourceNames(True);

  //User DSNs
  
GetDataSourceNames(False);
end;

Rate this tip:

poor
very good


Copyright © Torry's Delphi Pages Torry's Delphi Pages Maintained by Simon Grossenbacher Notes? Comments? Feel free to send... Copyright © 1996-2001