Software snipets for the Delphi & Pascal Community
Sep 05, 2010 - 04:53 AM
alt1
Borland :: Mailing Lists
alt1
Search  
alt1
alt1 alt1 alt1
alt1
Main Menu
alt1
· Home
· Your Account

Other Options

· AvantGo
· Downloads
· FAQ
· Members List
· Messages
· News
· Recommend Us
· Reviews
· Search
· Sections
· Stats
· Submit News
· Topics
· Top List
· Web Links

alt1
Who's online
alt1
There are currently, 7 guest(s) and 0 member(s) online.

You are an anonymous user. You can register for free by clicking here


alt1
alt1
Put stuff in the Registry instead of an INI file
Posted by: Gayle
alt1
Topic Registry/INI
Are you sick on using INI files why not store your information .. this let's you store stuff in the registry



// Are you sick on using INI files why not store your information
// in a binary format it the registry.
// Copy / Paste the object below or download it from our site
// To view the registry key load Regedit.exe
// and search for Store_INI.

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,registry, Dialogs,
StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

Type TSE = Packed Record
Name: String;
Age : String;
End;

var
Form1: TForm1;
Setup: TSE;
implementation

{$R *.DFM}


Procedure ReadWriteSetup(Stat: Boolean);
Var Reg: TRegistry;
Path: String;
begin
Case Stat of
True:
Begin
Reg := TRegistry.Create;
try
with Reg do
begin
RootKey := HKEY_LOCAL_MACHINE;
Path := 'SOFTWARE\Microsoft\Windows\CurrentVersion\test\store_INI';
If KeyExists(Path) Then
Begin
Openkey(path,False);
WriteBinarydata('Setup',setup,Sizeof(setup));
End;
End;
Finally
reg.CloseKey;
Reg.Free;
End;
End;
False:
Begin
Begin
Reg := TRegistry.Create;
try
with Reg do
begin
RootKey := HKEY_LOCAL_MACHINE;
Path := 'SOFTWARE\Microsoft\Windows\CurrentVersion\test\store_INI';
If KeyExists(Path) Then
Begin
Openkey(path,False);
ReadBinarydata('Setup',setup,Sizeof(setup));

End;
End;
Finally
reg.CloseKey;
Reg.Free;
End;
End;
End;

End;
End;

procedure TForm1.Button1Click(Sender: TObject);
begin
Setup.Name := 'Colin';
Setup.Age := '14';
ReadWriteSetup(true);

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
ReadWriteSetup(False);
With Memo1.lines DO
Begin
Add(Setup.Name);
Add(Setup.Age);
End;

end;


alt1
alt1
 
alt1
Login
alt1
Username

Password

Don't have an account yet? You can create one. As a registered user you have some advantages like a theme manager, comments configuration and posting comments with your name.

alt1
Related links
alt1
· More about Registry/INI
· News by admin


Most read story in Registry/INI:
Put stuff in the Registry instead of an INI file


Printer friendly page  Send this story to a friend

alt1
Report Bugs :: Tasks :: Developers 
alt1




alt1