View Full Version : How do use the TRegistry.ReadBinary thing
I can read/write strings and integer no probs, but when it comes to binary (i.e. IP address) I don't know what to do with it.
I know nout about buffers, pointers etc, so if some one could write an example of how to retrieve and write data in binary it would be mucho appreciated!
Here's a quick example:
procedure ReadBinary( ... ); * * * * * * * * * * * * * * * * * * * * * aRootKey *: String * * );
var
* *aKey * * * * *: String;
* *aName * * * * : String;
* *aDataSize * * : Integer;
* *aDataType * * : TRegDataType;
* *aBuffer * * * : Pointer;
begin
* *aKey *:= '...'; //Insert Key Here
* *aName := '...'; //Insert Value Name Here
* *if ( aRegistry.OpenKey( aKey, FALSE ) = TRUE ) then
* *begin
* * * *if ( aRegistry.ValueExists( aName ) = TRUE ) then
* * * *begin
* * * * * *{ Gather data information for the key/value }
* * * * * *aDataSize := aRegistry.GetDataSize( aName );
* * * * * *aDataType := aRegistry.GetDataType( aName );
* * * * * *
* * * * * *if ( aDataType = rdBinary ) then
* * * * * *begin
* * * * * * * *GetMem *( aBuffer, *aDataSize );
* * * * * * * *FillChar( aBuffer^, aDataSize, 0 );
* * * * * * * *aRegistry.ReadBinaryData( aName, aBuffer^, aDataSize );
* * * * * * * *... //Use the data
* * * * * * * *FreeMem ( aBuffer, *aDataSize );
* * * * * *end;
* * * *end;
* *end;
end;
---
You don't have to check the data type if you don't want to, but it's a safe thing to do.
Basically you just have to allocate the memory at the pointer location. *Then use the data and free the memory. *You could use a static buffer if you like.
Blake Schwendiman
Pythoness Software
http://www.pythoness.com
Sorry mate but I don't really understand all that.
I want to read the IP address from registry, then put the address in an edit box, then edit it, and save back in binary!
PLEASE HELP !
Send me the key and value names in the Registry
and I'll post an example.
usear
02-07-2001, 10:21 AM
hi, Id like a copy of the code too,
Basically I am trying to read IP address and Default gateway under windows NT and possible wirte back too
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.