Solved

ReadBinaryData

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

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month4 days, 4 hours left to enroll

630 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