Solved

get all dsn from odbc

Posted on 2001-07-25
5
149 Views
Last Modified: 2010-04-06
names and properties (like database driver).

thanks
0
Comment
Question by:jpcs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 21

Accepted Solution

by:
gemarti earned 50 total points
ID: 6319353
The way I've been going today I'm almost afraid to post but here:

procedure TForm1.Button1Click(Sender: TObject);
var
  Reg: TRegistry;
  Val : TStringList;
  I : Integer;
begin
  Reg := TRegistry.Create;
  Val := TStringList.Create;
  try
    Reg.RootKey := HKEY_CURRENT_USER;
    if Reg.OpenKey('\Software\ODBC\ODBC.INI', False)
    then
      begin
        Reg.GetKeyNames(Val);
        For I := 0 to Val.Count - 1 do
          begin
            ListBox1.Items.Add(Val.Strings[i]);
          end;
      end;
  finally
    Reg.CloseKey;
    Reg.Free;
    Val.Free;
    inherited;
  end;

end;
0
 
LVL 21

Expert Comment

by:gemarti
ID: 6319734
Change these two lines to get the System dsn's on the system

   Reg.RootKey := HKEY_LOCAL_MACHINE;
   if Reg.OpenKey('\Software\ODBC\ODBC.INI', False)


BTW you also need to add Registry to the uses clause.
0
 
LVL 1

Expert Comment

by:rootnash
ID: 6321017
add these for the properties....


procedure TForm1.ListBox1Click(Sender: TObject);
var
 Reg: TRegistry;
 Val: TStringList;
 I  : Integer;
 st : string;
begin
 Reg  := TRegistry.Create;
 Val  := TStringList.Create;
 try
   Listbox2.Clear;
   ListBox3.Clear;
   st := ListBox1.Items.Strings[ListBox1.ItemIndex];
   Reg.RootKey := HKEY_CURRENT_USER;
   if Reg.OpenKey('\Software\ODBC\ODBC.INI\'+ st, False) then
     begin
       Reg.GetValueNames(Val);
       For I := 0 to Val.Count - 1 do
         begin
           ListBox2.Items.Add(Val.Strings[i]);
           ListBox3.Items.Add('"'+Reg.ReadString(Val.Strings[I])+'"');
         end;
     end;
 finally
   Reg.CloseKey;
   Reg.Free;
   Val.Free;
   inherited;
 end;
end;


include another 2 listboxes, ListBox2(Name) and ListBox3(Data)
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6842796
Question(s) below appears to have been abandoned. Your options are:
 
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you. You must tell the participants why you wish to do this, and allow for Expert response.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question. Again, please comment to advise the other participants why you wish to do this.

For special handling needs, please post a zero point question in the link below and include the question QID/link(s) that it regards.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process.  Click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, in the event new items have been created since this listing was pulled.

http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.11700518.html
http://www.experts-exchange.com/questions/Q.11747200.html
http://www.experts-exchange.com/questions/Q.20092793.html
http://www.experts-exchange.com/questions/Q.20132046.html
http://www.experts-exchange.com/questions/Q.20156965.html
http://www.experts-exchange.com/questions/Q.20174271.html
http://www.experts-exchange.com/questions/Q.20246680.html
http://www.experts-exchange.com/questions/Q.20258192.html


PLEASE DO NOT AWARD THE POINTS TO ME.  
 
------------>  EXPERTS:  Please leave any comments regarding this question here on closing recommendations if this item remains inactive another three days.
 
Thank you everyone.
 
Moondancer
Moderator @ Experts Exchange

P.S.  For any year 2000 questions, special attention is needed to ensure the first correct response is awarded, since they are not in the comment date order, but rather in Member ID order.
0
 
LVL 5

Expert Comment

by:Netminder
ID: 6903298
Force-accepted by
Netminder
CS Moderator
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question