Solved

Delphi Programming question

Posted on 1997-06-20
5
142 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
  • 3
  • 2
5 Comments
 
LVL 4

Expert Comment

by:erajoj
Comment Utility
Send the code and i'll have a look.

/// John
0
 
LVL 2

Author Comment

by:Dane Pickering
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Well, thanks alot for the nil-pointer... :-)

/// John

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Firewall issues 6 84
delphi custom sort exception 6 109
Delphi XE10 Round Image 2 48
How to debug For loops? 3 33
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

771 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

10 Experts available now in Live!

Get 1:1 Help Now