Solved

ReadBinaryData

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

911 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

17 Experts available now in Live!

Get 1:1 Help Now