Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to read binary values from the registry Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
28-Sep-02
Category
Win API
Language
Delphi 2.x
Views
134
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			 Author: William Gerbert

I want to read out the binary value "problems" of the path HKEY_DYN_DATA\Config 
Manager\Enum\[add the key of a hardware component] to detect if a hardware 
component is troubled and not working right. But I cannot handle the 
ReadBinaryData-Method of TRegistry correct. Everytime I use it, it always returns 
"4" as content of the buffer. How do I detect if the content of the binary key 
"problems" is not "00 00 00 00" but something else like "16 00 00 00" or such?

Answer:

Here's an example of ReadBinaryData:


1   procedure TFrmReadBinary.Button1Click(Sender: TObject);
2   const
3     CKeyName: string = 'System\Setup';
4     CValName: string = 'NetcardDlls';
5   var
6     keyGood: boolean;
7     p: integer;
8     regKey: TRegistry;
9     tmpStr: string;
10    vSize: integer;
11  begin
12    regKey := TRegistry.Create;
13    try
14      regKey.RootKey := HKEY_LOCAL_MACHINE;
15      keyGood := regKey.OpenKey(CKeyName, false);
16      if (keyGood) then
17      begin
18        vSize := regKey.GetDataSize(CValName);
19        if (vSize > 0) then
20        begin
21          SetLength(tmpStr, vSize);
22          regKey.ReadBinaryData(CValName, tmpstr[1], vSize);
23          repeat
24            p := Pos(#0, tmpStr);
25            if p <> 0 then
26            begin
27              Delete(tmpStr, p, 1);
28              Insert(#13#10, tmpStr, p);
29            end;
30          until
31            p = 0;
32          {StringReplace(tmpStr, #0, #13#10, [rfReplaceAll]);}
33          ListBox1.Items.Text := tmpStr;
34        end;
35      end;
36    finally
37      regKey.Free;
38    end;
39  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC