Solved

ReadBinaryData

Posted on 1998-11-04
5
153 Views
Last Modified: 2010-04-04
I need to know how to read from the Registry.  I got to read a binary text.

Please help!!!
0
Comment
Question by:MichaelB99
  • 3
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
philipleighs earned 200 total points
ID: 1345678
var reg: TRegistry;
      Key: string;
      Value: string;
      Buffer: array [0..256] of byte;
begin
   Key := 'Your path';  // eg 'Software\Microsoft\Windows\'
   Value := 'The item to read';

  reg := TRegistry.Create;
  try
    if reg.OpenKey(Key) then
      begin
        reg.ReadBinaryData(Value, Buffer, SizeOf(Buffer));
        reg.CloseKey;
     end;
  finally
    reg.Free;
  end;


Sorry for any syntax errors, this is just from memory.
If the value doesn't exist, then an exception is raised.
0
 
LVL 3

Expert Comment

by:philipleighs
ID: 1345679
Hi,

Just rereading your question, if it is a string that you want to read, replace reg.ReadBinaryData with reg.ReadString(Value);
This will return a string containing the data.
0
 

Author Comment

by:MichaelB99
ID: 1345680
I am trying to read "ProxyEnable" from the internet settings.  The value reads "00 00 00 00" for false and "01 00 00 00" for true.  How would I be able to tell the difference?

The location is:
 
HKEY_CURRENT_USER
\Software\Microsoft\Windows\CurrentVersion\Internet Settings\

btw- you got to set Reg.RootKey := HKEY_CURRENT_USER
0
 

Author Comment

by:MichaelB99
ID: 1345681
I am trying to read "ProxyEnable" from the internet settings.  The value reads "00 00 00 00" for false and "01 00 00 00" for true.  How would I be able to tell the difference?

The location is:
 
HKEY_CURRENT_USER
\Software\Microsoft\Windows\CurrentVersion\Internet Settings\

btw- you got to set Reg.RootKey := HKEY_CURRENT_USER
0
 
LVL 3

Expert Comment

by:philipleighs
ID: 1345682
Make Buffer a DWORD,
compare it to $01000000 to see if it is true.

var Buffer: DWORD;

//do the stuff above
.

if Buffer = $01000000 then
   showmessage('proxy enabled')
else
   showmessage('proxy disabled');

You don't actually need to set RootKey to current user, when you create a TRegistry object, the default root is current user.
If you wanted local machine then you'd need to set it.

Cheers.

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now