Solved

Reading from Registry

Posted on 2004-09-24
8
203 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
[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
  • 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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This is about my first experience with programming Arduino.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.

734 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