Mega Code Archive

 
Categories / Delphi / Examples
 

Read write data to the registry handy for storing information

How to add information to the registry ShellSPY V1.1a is the award winning and powerful monitoring solution that you need! ShellSPY gives you the power to log all keystrokes, windows viewed, applications ran, internet connections made, passwords entered, chat conversations that were made, Monitor all running tasks on your pc Download Now Web Site: Cjpsoftware.com // 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;