Solved

ReadBinaryData

Posted on 1998-11-04
5
158 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
[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
  • 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
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…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

739 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