Thanks for your comment - I wasn't sure about whether I had been clear enough in my question so this is a great start.
First question here. Say I have 10 users - what is the best way of managing them in the program so I can select any one of them from a list box? I kind of imagined some kind of array of the type that has an index so I can ask for record 1,2,3,4 or whatever. I have a long background in VB so I understand perfectly how to do it in that environment, but I am trying to understand how it works in Delphi.
Secondly, I can see your point about saving this info to a file. Maybe if you had some code illustrating that it would help. I am willing to raise the points on this question.
Thanks for your help.
Main Topics
Browse All Topics





by: Slick812Posted on 2002-08-26 at 22:50:13ID: 7244272
hello bubbles, it's not so difficult to write binary data to the registry, but it seems like it would be better and faster to write your user data to a file and read the info from the file. Here is some code that will write and read a UserData Type to and from the Registry
Sender: TObject); urAppName' , True) 1',UserDat a1, SizeOf(UserData1));;
ender: TObject); urAppName' , False) ',UserData 1, SizeOf(UserData1));; eSize));
type
TUserData = Record
Number: Integer;
FirstName: Array[0..14] of Char;
MiddleIni: Char;
LastName: Array[0..16] of Char;
Account: Word;
ARect: TRect;
ShoeSize: Single;
end;
procedure TForm1.sbut_Save2RegClick(
var
Reg1: TRegistry;
UserData1: TUserData;
begin
UserData1.Number := 876121;
UserData1.FirstName := 'Mikey';
UserData1.MiddleIni := 'G';
UserData1.LastName := 'MacFerson, Levy';
UserData1.Account := 321;
UserData1.ARect := Rect(43, 127, 234, 382);
UserData1.ShoeSize := 11.5;
Reg1 := TRegistry.Create;
try
Reg1.RootKey := HKEY_CURRENT_USER;
if Reg1.OpenKey('\Software\Yo
then begin
Reg1.WriteBinaryData('user
Reg1.CloseKey;
end else ShowMessage('No GO');
finally
Reg1.Free;
end;
end;
procedure TForm1.sbut_ReadRegClick(S
var
Reg1: TRegistry;
UserData1: TUserData;
begin
Reg1 := TRegistry.Create;
try
Reg1.RootKey := HKEY_CURRENT_USER;
if Reg1.OpenKey('\Software\Yo
then begin
Reg1.ReadBinaryData('user1
Reg1.CloseKey;
end else ShowMessage('No GO');
finally
Reg1.Free;
end;
if UserData1.Number = 876121 then
ShowMessage('Name is '+UserData1.FirstName+' '+UserData1.MiddleIni+'. '+UserData1.LastName+' ShoeSize is '+FloatToStr(UserData1.Sho
end;
- - - - - - - - - - - - - - - - - - - - - - - -
hope this helps you, ask questions if you need more info.