Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Delphi Programming question

Posted on 1997-06-20
5
Medium Priority
?
150 Views
Last Modified: 2010-04-04
What i want to do is to write a binary value (record called Settings) into the registry as a binary instead of to a file. It is 176 bytes in length and for the life of me i can't get the WriteBinaryData to work.  I know this will be something simple. Could someone please post me a small sample of code that i need and what parms to put where to get this procedure working. and how do you tell it what binary data to write to it.

Thanks.
Dane.

--- Cut From Delphi 2 Help File.

Applies to

TRegistry object, TRegIniFile object

Declaration

procedure WriteBinaryData(const Name: string; var Buffer; BufSize: Integer);
0
Comment
Question by:Dane Pickering
[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 4

Expert Comment

by:erajoj
ID: 1337350
Send the code and i'll have a look.

/// John
0
 
LVL 2

Author Comment

by:Dane Pickering
ID: 1337351
i have no code to give, thats what i need a small sample of code with the correct way ti write a record to a registry. i need to know the correct way to do this.

Regards,
Dane.
0
 
LVL 4

Accepted Solution

by:
erajoj earned 0 total points
ID: 1337352
Hi again!

This really simple code does, hopefully, what you want.

procedure TMainForm.Button15Click(Sender: TObject);
type
  TTestRec = record
    Name  : string[10];
    Number: Comp;
  end;
var
  Ini: TRegistry;
  Rec: TTestRec;
begin
  Ini := TRegistry.Create;
  if Ini.OpenKey('\software\Dane\Recs', True)
  then begin
    with Rec do begin
      Name := 'Dane';
      Number := 8630007314.0;
    end;
    Ini.WriteBinaryData('TestBuffer', Rec, SizeOf(TTestRec));

    FillChar(Rec, SizeOf(TTestRec), 0); // Clear record contents

    Ini.ReadBinaryData('TestBuffer', Rec, SizeOf(TTestRec));
    with Rec do begin
      Caption := Format('%s - %.0f', [Name, Number]);
    end;
  end;
  Ini.Free;
end;

Enjoy!

/// John
0
 
LVL 2

Author Comment

by:Dane Pickering
ID: 1337353
Ok, well that worked and that is exactly the same way that i was trying to get it to work. Umm, i couldn't see any difference, but al least it works. So you can have the points!

Thanks mate!

Regards,
Dane
0
 
LVL 4

Expert Comment

by:erajoj
ID: 1337354
Well, thanks alot for the nil-pointer... :-)

/// John

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

721 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