Articles   Members Online: 3
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to get ODBC datasource names Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
14-Jun-04
Category
DB-General
Language
Delphi All Versions
Views
296
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
Darley, F. Joe
Reference URL:
			1   
2   unit Unit1;
3   
4   interface
5   
6   uses
7     Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
8     Dialogs, StdCtrls,Registry;
9   
10  type
11    TForm1 = class(TForm)
12      Button1: TButton;
13      ListBox1: TListBox;
14      Button2: TButton;
15      procedure Button1Click(Sender: TObject);
16      procedure Button2Click(Sender: TObject);
17    private
18      { Private declarations }
19    public
20      { Public declarations }
21      procedure GetDataSourceNames(System: Boolean);
22    end;
23  
24  var
25    Form1: TForm1;
26  
27  implementation
28  
29  {$R *.dfm}
30  
31  procedure TForm1.GetDataSourceNames(System: Boolean);
32  var
33    reg: TRegistry;
34  begin
35    ListBox1.Items.Clear;
36  
37    reg := TRegistry.Create;
38    try
39      if System then
40        reg.RootKey := HKEY_LOCAL_MACHINE
41      else
42        reg.RootKey := HKEY_CURRENT_USER;
43  
44      if reg.OpenKey('\Software\ODBC\ODBC.INI\ODBC Data Sources', False) then
45      begin
46        reg.GetValueNames(ListBox1.Items);
47      end;
48  
49    finally
50      reg.CloseKey;
51      FreeAndNil(reg);
52    end;
53  end;
54  
55  procedure TForm1.Button1Click(Sender: TObject);
56  begin
57    //System DSNs
58    GetDataSourceNames(True);
59  end;
60  
61  
62  procedure TForm1.Button2Click(Sender: TObject);
63  begin
64    //User DSNs
65    GetDataSourceNames(False);
66  end;
67  
68  end.
69  


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC