unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, LPL_Sysutils, enviroment, lplFindFile;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Button1: TButton;
    ListBox1: TListBox;
    Button2: TButton;
    find: TlplFindFile;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure findNewFolder(Sender: TObject; Folder: String);
    procedure findFound(Sender: TObject; Folder: String;
      FileInfo: TSearchRec);
    procedure findComplete(Sender: TObject);
  private
    { Private declarations }
  public
    Location: String;
    Procedure AddToLog(Str: String);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button2Click(Sender: TObject);
begin
 Application.Terminate;
end;

procedure TForm1.AddToLog(Str: String);
begin
 Listbox1.Items.add(Str);
 Listbox1.TopIndex := listbox1.Items.count-1;
 Application.ProcessMessages;
end;

procedure TForm1.Button1Click(Sender: TObject);
Var
 S: String;
begin
 button1.Enabled := false;
 addtolog('Looking for DLL file ...');
 S := ExtractfilePath(ParamStr(0));
 S := PathToOk(S) + 'PluginManagerDotNetAddon.dll';
 If not fileexists(S) then begin
  MessageDlg('Could not find the COM Object DLL'+#13+#10+''+#13+#10+'PlugInManagerDotNetAddon.dll'+#13+#10+''+#13+#10+'Please make sure it''s in the same directory as this util.', mtError, [mbAbort], 0);
  Application.terminate;
 End;
 addtolog('Looking for regasm.exe ...');
 Find.Path := Enviroment.GetSystemRoot;
 addtolog('Searching ' + Find.Path + ' ...');
 Find.Search;
end;

procedure TForm1.findNewFolder(Sender: TObject; Folder: String);
begin
 addtolog('Searching ' + Folder + ' ...');
end;

procedure TForm1.findFound(Sender: TObject; Folder: String;
  FileInfo: TSearchRec);
Var
 S: String;
begin
 AddToLog('Found');
 AddToLog('Installing ...');
 Location := PathtoOk(Folder) + Fileinfo.Name;
 S := ExtractfilePath(ParamStr(0));
 S := PathToOk(S) + 'PluginManagerDotNetAddon.dll';
 Execapp(location, '"-codebase" "' + S + '"');
 AddToLog('Done');
 halt;
end;

procedure TForm1.findComplete(Sender: TObject);
begin
 MessageDlg('REGASM.exe could not be found'+#13+#10+''+#13+#10+'Please make sure you have the Microsoft .NET framework '+#13+#10+'installed !', mtError, [mbOK], 0);
 application.Terminate;
end;

end.
