Solved

Reading from Registry

Posted on 2004-09-24
8
196 Views
Last Modified: 2013-11-13
Hey,

How would I do this code so when I click a button it searches under LOCAL_MACHINE\Software\MyAPP\Random and if the word in the edit box is the same as the one under that key it says Ok other wise it says Go Away.

Cheers,

Computer Programer
0
Comment
Question by:computerprogramer
  • 3
  • 3
8 Comments
 

Expert Comment

by:dan-g
ID: 12147622
Which language?
0
 

Author Comment

by:computerprogramer
ID: 12147637
Bugger!

I posted it in the wrong forum. It should be in Delphi. So the language is Delphi.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12147668
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

Author Comment

by:computerprogramer
ID: 12153579
I dont get that could someone else show me how to do this?
0
 

Expert Comment

by:dan-g
ID: 12154198
The "short answer" from the first of jaime olivares's links is this:

>> If you have a name of the value (string)then here are functions you need:
>> Tregistry.readstring
>> Tregistry.readfloat
>> Tregistry.readinteger
>> and so on...
>> Bye
>> Duke Nukem.

Here is a web page with more details & examples:

http://www.howtodothings.com/showarticle.asp?article=76

Here's a sample from that article:

-------------------------------------------
  uses Registry, Windows, Dialogs;

  procedure TForm1.Button1Click(Sender: TObject);
  var
    Reg: TRegistry;
  begin
    Reg := TRegistry.Create;
    Reg.RootKey := HKEY_LOCAL_MACHINE;
      if Reg.OpenKey('\Hardware\Description\System'
        + '\CentralProcessor\0', False) then begin
      ShowMessage(Reg.ReadString('Identifier'));
      Reg.CloseKey;
    end; // if
    Reg.Free;
  end;
-------------------------------------------

Does this answers your question?

Dan.
0
 

Author Comment

by:computerprogramer
ID: 12156217
Yes it kind of does,

Apart from I want to implement it so if the value = the text in the editbox then it will say word found.

Cheers
0
 

Accepted Solution

by:
dan-g earned 25 total points
ID: 12158960
Could be something like this (please note, I rarely work in Delphi and don't have a compiler installed, so there might be some syntax errors or typos):

-------------------------------------------
  uses Registry, Windows, Dialogs;

  procedure TForm1.Button1Click(Sender: TObject);
  var
    Reg: TRegistry;
  begin
    Reg := TRegistry.Create;
    Reg.RootKey := HKEY_LOCAL_MACHINE;
    if Reg.OpenKey('\Hardware\Description\System'
        + '\CentralProcessor\0', False) then
      begin
        Reg.ReadString('Identifier'));
        If Reg.ReadString('Identifier') = Edit1.Text then
          begin
          ShowMessage(Reg.ReadString('OK'));
          end
        else
          begin
          ShowMessage(Reg.ReadString('Go Away'));
          end;
        end; //if
      Reg.CloseKey;
    end; // if
    Reg.Free;
  end;
-------------------------------------------

I hope this completes the missing part...

Dan.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
This code tracks birthdays 3 72
Definitions and default visual studio colors 5 65
Help Required 3 93
Server 2012 Hypervisor 2 7
This is about my first experience with programming Arduino.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

776 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