Solved

Implement Registry

Posted on 2010-09-23
5
288 Views
Last Modified: 2012-06-21
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_22015173.html

That is the link of rllibbys answer for registry cleaning
Units are regsweeper and regutils

Can someone show me a simple application form using the regsweeper.

Thanks
0
Comment
Question by:systan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 32

Accepted Solution

by:
Ephraim Wangoya earned 500 total points
ID: 33750735
Heres my intepretation, and mmm I didn't test it


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, RegUtils, RegSweeper;

type
  TForm1 = class(TForm)
    btnScan: TButton;
    btnFix: TButton;
    btnCancel: TButton;
    Memo1: TMemo;
    procedure btnScanClick(Sender: TObject);
    procedure btnFixClick(Sender: TObject);
    procedure btnCancelClick(Sender: TObject);
  private
    FCanceled: Boolean;
    procedure StartFix(Sender: TObject; Count: Integer);
    procedure FinishFix(Sender: TObject; Fixed: Integer; Cancelled: Boolean);
    procedure StartScan(Sender: TObject);
    procedure FinishScan(Sender: TObject; Cancelled: Boolean);
    procedure StartGroupItem(Sender: TObject; ItemName: String; var Cancel: Boolean);
    procedure FinishGroup(Sender: TObject; GroupItem: TRegGroupClass; Operation: TRegOperation; var Cancel: Boolean);
    procedure FixItem(Sender: TObject; ItemName: String; Fixed: Boolean; var Cancel: Boolean);
    procedure GroupItem(Sender: TObject; ItemName: String; var Cancel: Boolean);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

{ TForm1 }

procedure TForm1.btnScanClick(Sender: TObject);
var
  RegSweeper: TRegSweeper;
begin
  try
    RegSweeper := TRegSweeper.Create;
    RegSweeper.OnGroupStart := StartGroupItem;
    RegSweeper.OnGroupItem := GroupItem;
    RegSweeper.OnGroupFinish := FinishGroup;
    RegSweeper.OnScanFinish := FinishScan;
    RegSweeper.OnScanStart := StartScan;
    RegSweeper.Scan;
  finally
    FreeAndNil(RegSweeper);
  end;
end;

procedure TForm1.btnFixClick(Sender: TObject);
var
  RegSweeper: TRegSweeper;
  Stream: TFileStream;
begin
  Stream := TFileStream.Create('c:\mybackup.reg', fmCreate);
  try
    try
      RegSweeper := TRegSweeper.Create;
      RegSweeper.OnGroupStart := StartGroupItem;
      RegSweeper.OnGroupItem := GroupItem;
      RegSweeper.OnGroupFinish := FinishGroup;
      RegSweeper.OnFixStart := StartFix;
      RegSweeper.OnFixItem := FixItem;
      RegSweeper.OnFixFinish := FinishFix;

      RegSweeper.Fix(Stream);
    finally
      FreeAndNil(RegSweeper);
    end;
  finally
    FreeAndNil(Stream);
  end;
end;

procedure TForm1.btnCancelClick(Sender: TObject);
begin
  FCanceled := True;
end;

procedure TForm1.FinishFix(Sender: TObject; Fixed: Integer; Cancelled: Boolean);
begin
  if Cancelled then
    Memo1.Lines.Add('User cancelled')
  else
    Memo1.Lines.Add('Finished fixing registry')
end;

procedure TForm1.FinishGroup(Sender: TObject; GroupItem: TRegGroupClass;
  Operation: TRegOperation; var Cancel: Boolean);
begin
  Cancel := FCanceled;
  if FCanceled then
    Exit;
  if Operation = roValidate then
    Memo1.Lines.Add('Finished validating group: ' + RegGroupClassName(GroupItem))
  else
    Memo1.Lines.Add('Finished loading group: ' + RegGroupClassName(GroupItem))
end;

procedure TForm1.FinishScan(Sender: TObject; Cancelled: Boolean);
begin
  if Cancelled then
    Memo1.Lines.Add('User cancelled')
  else
    Memo1.Lines.Add('Finished scanning registry')
end;

procedure TForm1.FixItem(Sender: TObject; ItemName: String; Fixed: Boolean;
  var Cancel: Boolean);
begin
  Cancel := FCanceled;
  if FCanceled then
    Exit;
  Memo1.Lines.Add('Fixing item: ' + ItemName);
end;

procedure TForm1.StartFix(Sender: TObject; Count: Integer);
begin
  Memo1.Lines.Clear;
  Memo1.Lines.Add('Started fix')
end;

procedure TForm1.StartGroupItem(Sender: TObject; ItemName: String;
  var Cancel: Boolean);
begin
  Cancel := FCanceled;
  if FCanceled  then
    Exit;
  Memo1.Lines.Add('Working on item: ' + ItemName)
end;

procedure TForm1.StartScan(Sender: TObject);
begin
  Memo1.Lines.Clear;
  Memo1.Lines.Add('Started Scan');
end;

end.

//dfm
object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 379
  ClientWidth = 512
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object btnScan: TButton
    Left = 360
    Top = 24
    Width = 121
    Height = 25
    Caption = 'Scan'
    TabOrder = 0
    OnClick = btnScanClick
  end
  object btnFix: TButton
    Left = 360
    Top = 71
    Width = 121
    Height = 25
    Caption = 'Backup && Fix'
    TabOrder = 1
    OnClick = btnFixClick
  end
  object btnCancel: TButton
    Left = 360
    Top = 120
    Width = 121
    Height = 25
    Caption = 'Cancel'
    TabOrder = 2
    OnClick = btnCancelClick
  end
  object Memo1: TMemo
    Left = 16
    Top = 16
    Width = 329
    Height = 345
    Lines.Strings = (
      '')
    TabOrder = 3
  end
end

Open in new window

0
 
LVL 14

Author Comment

by:systan
ID: 33764695
moved code into code snippet?
whats the meaning of that aikimark?
0
 
LVL 14

Author Comment

by:systan
ID: 33766125
Ah, Ok, I've noticed it.
Thanks.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

738 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