?
Solved

Implement Registry

Posted on 2010-09-23
5
Medium Priority
?
291 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 2000 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month9 days, 12 hours left to enroll

762 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