Solved

ReadBinaryData

Posted on 1998-11-04
5
157 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

830 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