 |
Put stuff in the Registry instead of an INI file
Posted by: Gayle |
|
 |
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;
|
 |
 |
| |
 |
|
|
 |
| 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. |
|