////////////////////////////////////////////////////////////////////////////////
// What's new
//
// Release Version x.x.x.x
//  * Added plugin filepath to all listviews
//
// Release Version 0.3.4.1
//  * Rebuilt with new core number
//
// Release Version 0.3.4.0
//  * Will update version numbers in the registry on load 
//
// Release Version 0.3.3.1
//  * Will launch OutlawEd on exit, if launched from it
//
// Release Version 0.3.3.0
//  * Plugin names can no longer be renamed
//  * Added ability to disable 8.3 names in windows
//
// Release VErsion 0.3.2.0
//  * Fixed an ICM2CMLxPlug2 installation bug
//
// Release Version 0.3.1.0
//  * Supports new CMLX Interface
//  * Sorts listviews by name column, not by GUID
//
// Release Version 0.3.0.0
//  * Shows plugin info for selected plugin on statusbar
//  * Saves View mode
//  * Sorting added when clicking on columns
//  * Error Dialog if trying to install a DLL that isn't a plugin
//  * Plugins Terminate routine is now ran on shutdown
//  * Fixed shutdown bug
//  * Multiple select under install plugins now possible
//
////////////////////////////////////////////////////////////////////////////////
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Menus, ExtCtrls, ComCtrls, ImgList, Cm2GenPlugTypes, CM2VisPlugtypes,
  CM2CMLxPlugTypes, CM2RegisterTools, lplListView, GDIPenable, XPMan; //cddGDIPenable,

type
  TForm1 = class(TForm)
    MainMenu: TMainMenu;
    File1: TMenuItem;
    Quit1: TMenuItem;
    StatusBar1: TStatusBar;
    LargeImg: TImageList;
    SmallImg: TImageList;
    PageControl: TPageControl;
    GenTab: TTabSheet;
    VisTab: TTabSheet;
    CMLxTab: TTabSheet;
    GenPop: TPopupMenu;
    Setup1: TMenuItem;
    Sensorlist1: TMenuItem;
    N1: TMenuItem;
    About1: TMenuItem;
    VisPop: TPopupMenu;
    CMLxPop: TPopupMenu;
    View1: TMenuItem;
    Icons1: TMenuItem;
    Details1: TMenuItem;
    Setup2: TMenuItem;
    PlugInInformation1: TMenuItem;
    N2: TMenuItem;
    About2: TMenuItem;
    Setup3: TMenuItem;
    PlugInInformation2: TMenuItem;
    N3: TMenuItem;
    About3: TMenuItem;
    N4: TMenuItem;
    UninstallPlugIn1: TMenuItem;
    Panel1: TPanel;
    HeaderControl1: THeaderControl;
    TreeView1: TTreeView;
    Splitter1: TSplitter;
    LargeImgBackup: TImageList;
    SmallImgBackup: TImageList;
    XPManifest1: TXPManifest;
    N5: TMenuItem;
    Uninstall1: TMenuItem;
    N6: TMenuItem;
    UninstallPlugIn2: TMenuItem;
    N7: TMenuItem;
    InstallPlugins1: TMenuItem;
    OpenDialog1: TOpenDialog;
    Panel2: TPanel;
    Splitter2: TSplitter;
    ListView1: TListView;
    Help1: TMenuItem;
    About4: TMenuItem;
    Debugging1: TMenuItem;
    ShowVerboseWindow1: TMenuItem;
    VisList: TlplListView;
    GenList: TlplListView;
    CMLxList: TlplListView;
    ools1: TMenuItem;
    dis83: TMenuItem;
    GDIPenable1: TGDIPenable;
    procedure Quit1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Setup1Click(Sender: TObject);
    procedure Sensorlist1Click(Sender: TObject);
    procedure Icons1Click(Sender: TObject);
    procedure Details1Click(Sender: TObject);
    procedure Setup2Click(Sender: TObject);
    procedure PlugInInformation1Click(Sender: TObject);
    procedure Setup3Click(Sender: TObject);
    procedure PlugInInformation2Click(Sender: TObject);
    procedure About1Click(Sender: TObject);
    procedure About2Click(Sender: TObject);
    procedure About3Click(Sender: TObject);
    procedure UninstallPlugIn1Click(Sender: TObject);
    procedure GenListSelectItem(Sender: TObject; Item: TListItem;
      Selected: Boolean);
    procedure TreeView1Expanding(Sender: TObject; Node: TTreeNode;
      var AllowExpansion: Boolean);
    procedure PageControlChange(Sender: TObject);
    procedure Uninstall1Click(Sender: TObject);
    procedure UninstallPlugIn2Click(Sender: TObject);
    procedure VisListSelectItem(Sender: TObject; Item: TListItem;
      Selected: Boolean);
    procedure InstallPlugins1Click(Sender: TObject);
    procedure About4Click(Sender: TObject);
    procedure TreeView1Collapsed(Sender: TObject; Node: TTreeNode);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure ShowVerboseWindow1Click(Sender: TObject);
    procedure CMLxListSelectItem(Sender: TObject; Item: TListItem;
      Selected: Boolean);
    procedure dis83Click(Sender: TObject);
  private
    shuttingDown: Boolean;
  public
    LaunchOnClose: String;
    DebugLevel: Integer;
    GPL: TGenPlugInList;
    VPL: TVisPlugInList;
    CPL: TCMLxPlugInList;
    TreeGP: PGenPlugIn;
    Procedure LoadPlugins;
  end;

var
  Form1: TForm1;

Const
  RegLocation = '\Software\The CoolMon Project\PlugIn Management\';

implementation

Uses Registry, ShellApi, PlugInInfoDlg, Unit2, CM2PlugInTypes, Unit3,
  verbose, LPL_Sysutils, Windows10;

{$R *.dfm}

procedure TForm1.LoadPlugins;
Var
 I: Integer;
 Reg: TRegistry;
 SIcon, LIcon: TIcon;
 LargeIcon, SmallIcon: HICON;
 Count: Integer;
 LI: TListItem;
 FName: String;
 Icon: TIcon;
 C: Cardinal;
begin
 LargeImg.Clear;
 SmallImg.Clear;
 For I := 0 to LargeImgBackup.Count - 1 do begin
  Icon := TIcon.Create;
  LargeImgBackup.GetIcon(I, Icon);
  LargeImg.AddIcon(Icon);
  FreeAndNil(Icon);
 end;
 For I := 0 to SmallImgBackup.Count - 1 do begin
  Icon := TIcon.Create;
  SmallImgBackup.GetIcon(I, Icon);
  SmallImg.AddIcon(Icon);
  FreeAndNil(Icon);
 end;
 Reg := TRegistry.Create;
 GPL.LoadAll;
 GenList.Selected := nil;
 GenList.Items.Clear;
 For I := 0 to GPL.Count - 1 do begin
  LI := GenList.Items.Add;
  LI.Caption := GPL[I].Name;
  LI.SubItems.Add(IntToStr(GPL[I].Version));
  LI.SubItems.Add(IntToStr(GPL[I].RequiredCoreVersion));
  LI.SubItems.Add(IntToStr(GPL[I].SensorList.Count));
  Reg.RootKey := HKEY_CURRENT_USER;
  Reg.OpenKey('\Software\The CoolMon Project\CertifiedPlugins\General\' + GUIDToString(GPL[I].GUID), true);
  Reg.WriteInteger('Version', GPL[I].Version);
  Reg.WriteInteger('RequiredCoreVersion', GPL[I].RequiredCoreVersion);
  LI.Subitems.Add(Reg.ReadString('Filename'));
  LI.SubItems.Add(IntToStr(I));
  Reg.CloseKey;
  LI.ImageIndex := 0;
  Reg.RootKey := HKEY_CLASSES_ROOT;
  If Reg.OpenKey('\CLSID\' + GUIDToString(GPL[I].GUID) + '\InProcServer32', false) then begin
   FName := Reg.ReadString('');
   If Fileexists(FName) then begin
    Count := ExtractIconEx(Pchar(Fname), -1, largeicon, smallicon, 1);
    If Count > 0 then begin
     ExtractIconEx(PChar(Fname), 0, largeicon, smallicon, 1);
     SIcon := TIcon.Create;
     SIcon.Handle := SmallIcon;
     SmallImg.AddIcon(SIcon);
     FreeAndNil(SIcon);
     LIcon := TIcon.Create;
     LIcon.Handle := LargeIcon;
     LI.ImageIndex := LargeImg.AddIcon(LIcon);
     FreeAndNil(LIcon);
    End;
   end;
  end;
 end;
 GenList.Update;
 VPL.LoadAll;
 VisList.Selected := nil;
 VisList.Items.Clear;
 For I := 0 to VPL.Count - 1 do begin
  LI := VisList.Items.Add;
  LI.Caption := VPL[I].Name;
  LI.SubItems.Add(IntToStr(VPL[I].Version));
  LI.SubItems.Add(IntToStr(VPL[I].RequiredCoreVersion));
  Case VPL[I].InterfaceVersion of
   1: LI.SubItems.Add('No');
   2: LI.SubItems.Add('Unknown');
   3: Begin
       If VPL[I].PlugIn3.NotifyOnEvent(C) <> E_FAIL then LI.SubItems.Add('Yes')
        else LI.SubItems.Add('No');
      End;
   4: Begin
       If VPL[I].PlugIn4.NotifyOnEvent(C) <> E_FAIL then LI.SubItems.Add('Yes')
        else LI.SubItems.Add('No');
      End;
  end;
  Reg.RootKey := HKEY_CURRENT_USER;
  Reg.OpenKey('\Software\The CoolMon Project\CertifiedPlugins\Visual\' + GUIDToString(VPL[I].GUID), true);
  Reg.WriteInteger('Version', VPL[I].Version);
  Reg.WriteInteger('RequiredCoreVersion', VPL[I].RequiredCoreVersion);
  LI.Subitems.Add(Reg.ReadString('Filename'));
  LI.SubItems.Add(IntToStr(I));
  Reg.CloseKey;
  LI.ImageIndex := 0;
  Reg.RootKey := HKEY_CLASSES_ROOT;
  If Reg.OpenKey('\CLSID\' + GUIDToString(VPL[I].GUID) + '\InProcServer32', false) then begin
   FName := Reg.ReadString('');
   If Fileexists(FName) then begin
    Count := ExtractIconEx(Pchar(Fname), -1, largeicon, smallicon, 1);
    If Count > 0 then begin
     ExtractIconEx(PChar(Fname), 0, largeicon, smallicon, 1);
     SIcon := TIcon.Create;
     SIcon.Handle := SmallIcon;
     SmallImg.AddIcon(SIcon);
     FreeAndNil(SIcon);
     LIcon := TIcon.Create;
     LIcon.Handle := LargeIcon;
     LI.ImageIndex := LargeImg.AddIcon(LIcon);
     FreeAndNil(LIcon);
    End;
   end;
  end;
 end;
 VisList.Update;
 CPL.LoadAll;
 CMLxList.Selected := nil;
 CMLxList.Items.Clear;
 For I := 0 to CPL.Count - 1 do begin
  LI := CMLxList.Items.Add;
  LI.Caption := CPL[I].Name;
  LI.SubItems.Add(IntToStr(CPL[I].Version));
  LI.SubItems.Add(IntToStr(CPL[I].RequiredCoreVersion));
  LI.SubItems.Add(CPL[I].TagName);
  Reg.RootKey := HKEY_CURRENT_USER;
  Reg.OpenKey('\Software\The CoolMon Project\CertifiedPlugins\CMLX\' + GUIDToString(CPL[I].GUID), true);
  Reg.WriteInteger('Version', CPL[I].Version);
  Reg.WriteInteger('RequiredCoreVersion', CPL[I].RequiredCoreVersion);
  LI.Subitems.Add(Reg.ReadString('Filename'));
  LI.SubItems.Add(IntToStr(I));
  Reg.CloseKey;
  LI.ImageIndex := 0;
  If Reg.OpenKey('\CLSID\' + GUIDToString(CPL[I].GUID) + '\InProcServer32', false) then begin
   FName := Reg.ReadString('');
   If Fileexists(FName) then begin
    Count := ExtractIconEx(Pchar(Fname), -1, largeicon, smallicon, 1);
    If Count > 0 then begin
     ExtractIconEx(PChar(Fname), 0, largeicon, smallicon, 1);
     SIcon := TIcon.Create;
     SIcon.Handle := SmallIcon;
     SmallImg.AddIcon(SIcon);
     FreeAndNil(SIcon);
     LIcon := TIcon.Create;
     LIcon.Handle := LargeIcon;
     LI.ImageIndex := LargeImg.AddIcon(LIcon);
     FreeAndNil(LIcon);
    End;
   end;
  end;
 end;
 CMLxList.Update;
 GenList.SortColumn := -1;
 VisList.SortColumn := -1;
 CMLxList.SortColumn := -1;
 GenList.SortColumn := 0;
 VisList.SortColumn := 0;
 CMLxList.SortColumn := 0;
end;

procedure TForm1.Quit1Click(Sender: TObject);
Var
 Reg: TRegistry;
 Sel, I: Integer;
begin
 Reg := TRegistry.Create;
 Reg.RootKey := HKEY_CURRENT_USER;
 Reg.OpenKey(RegLocation, true);
 Reg.WriteBool('ShowIcons', GenList.ViewStyle = vsIcon);
 For I := 0 to GenList.items.count - 1 do begin
  Sel := StrToInt(GenList.Items[I].SubItems[4]);
  If Reg.OpenKey(PathToOk(CertifiedGENPlugInsLocation) + GUIDTOString(GPL[Sel].GUID), false) then begin
   Reg.WriteBool('AlwaysLoad', GenList.Items[I].Checked);
  end;
 end;
 For I := 0 to VisList.items.count - 1 do begin
  Sel := StrToInt(VisList.Items[I].SubItems[4]);
  If Reg.OpenKey(PathToOk(CertifiedVISPlugInsLocation) + GUIDTOString(VPL[Sel].GUID), false) then begin
   Reg.WriteBool('AlwaysLoad', VisList.Items[I].Checked);
  end;
 end;
 Reg.CloseKey;
 FreeAndNil(Reg);
 Treeview1.Items.Clear;
 GenList.Selected := Nil;
 VisList.Selected := Nil;
 CmlxList.Selected := Nil;
 FreeAndNil(GPL);
 FreeAndNil(VPL);
 FreeAndNil(CPL);
 If LaunchOnClose <> '' then begin
  If fileexists(LaunchOnClose) then begin
   Execapp(LaunchOnClose);
  end;
 end;
 Application.Terminate;
end;

procedure TForm1.FormCreate(Sender: TObject);
Var
 Reg: TRegistry;
 I: Integer;
 B: Boolean;
begin
 If Not HasAdminAccess then
  RestartApplicationWithElevatedPriviliges;

 Reg := TRegistry.Create;
 Reg.OpenKey(RegLocation, true);
 Reg.WriteString('', application.ExeName);
 If Reg.ValueExists('ShowIcons') then begin
  B := Reg.ReadBool('ShowIcons');
  If B Then Icons1Click(self)
   else Details1Click(self);
 end;
 Reg.OpenKey('\', false);
 Reg.RootKey := HKEY_LOCAL_MACHINE;
 If Reg.OpenKey('\System\CurrentControlSet\Control\Filesystem', false) then begin
  Dis83.Enabled := true;
  Dis83.Checked := Reg.ReadInteger('NtfsDisable8dot3NameCreation') = 1;
 end
  else
 begin
  // 8.3 disable ability not found, gray out function.
  Dis83.Enabled := False;
 end;
 reg.CloseKey;
 shuttingdown := False;
 GPL := TGenPlugInList.Create(handle);
 VPL := TVisPlugInList.Create;
 CPL := TCMLxPlugInList.Create(handle);
 Self.LoadPlugins;
 LaunchOnClose := '';
 For I := 1 to paramcount do begin
  If uppercase(ParamStr(I)) = '/DEBUG' then Debugging1.Visible := true;
  If uppercase(ParamStr(I)) = '/LAUNCHEDITOR' then begin
   Reg.RootKey := HKEY_CURRENT_USER;
   If Reg.OpenKey('\Software\The coolmon project\coolmon2\editor', false) then begin
    LaunchOnClose := Reg.ReadString('');
   end;
  end;
 end;
 freeandnil(reg);
 Self.PageControlChange(self);
end;

procedure TForm1.Setup1Click(Sender: TObject);
begin
 If GenList.Selected = nil then exit;
 GPL[StrToInt(GenList.Selected.SubItems[4])].Setup;
end;

procedure TForm1.Sensorlist1Click(Sender: TObject);
begin
 If GenList.Selected = nil then exit;
 Form5.Execute(GPL[StrToInt(GenList.Selected.SubItems[4])]);
end;

procedure TForm1.Icons1Click(Sender: TObject);
begin
 Icons1.Checked := true;
 Details1.Checked := False;
 GenList.ViewStyle := vsIcon;
 VisList.ViewStyle := vsIcon;
 CMLxList.ViewStyle := vsIcon;
end;

procedure TForm1.Details1Click(Sender: TObject);
begin
 Icons1.Checked := false;
 Details1.Checked := true;
 GenList.ViewStyle := vsReport;
 VisList.ViewStyle := vsReport;
 CMLxList.ViewStyle := vsReport;
end;

procedure TForm1.Setup2Click(Sender: TObject);
begin
 If VisList.Selected = nil then exit;
 VPL[StrToInt(VisList.Selected.SubItems[4])].Setup;
end;

procedure TForm1.PlugInInformation1Click(Sender: TObject);
begin
 If VisList.Selected = nil then exit;
 Form5.Execute(VPL[StrToInt(VisList.Selected.SubItems[4])]);
end;

procedure TForm1.Setup3Click(Sender: TObject);
begin
 If CMLxList.Selected = nil then exit;
 CPL[StrToInt(CMLxList.Selected.SubItems[4])].Setup;
end;

procedure TForm1.PlugInInformation2Click(Sender: TObject);
begin
 If CMLxList.Selected = nil then exit;
 Form5.Execute(CPL[StrToInt(CMLxList.Selected.SubItems[4])]);
end;

procedure TForm1.About1Click(Sender: TObject);
Var
 Icon: TIcon;
begin
 Icon := TIcon.Create;
 LargeImg.GetIcon(GenList.Selected.ImageIndex, Icon);
 Form2.Execute(GPL[StrToInt(GenList.Selected.SubItems[4])], Icon);
 FreeAndNil(Icon);
end;

procedure TForm1.About2Click(Sender: TObject);
Var
 Icon: TIcon;
begin
 Icon := TIcon.Create;
 LargeImg.GetIcon(VisList.Selected.ImageIndex, Icon);
 Form2.Execute(VPL[StrToInt(VisList.Selected.SubItems[4])], Icon);
 FreeAndNil(Icon);
end;

procedure TForm1.About3Click(Sender: TObject);
Var
 Icon: TIcon;
begin
 Icon := TIcon.Create;
 LargeImg.GetIcon(CMLxList.Selected.ImageIndex, Icon);
 Form2.Execute(CPL[StrToInt(CMLxList.Selected.SubItems[4])], Icon);
 FreeAndNil(Icon);
end;

procedure TForm1.UninstallPlugIn1Click(Sender: TObject);
Var
 RT: TRegisterTools;
 Sel: Integer;
 GUID: TGUID;
begin
 If genlist.Selected = nil then exit;
 if (MessageDlg('Are you sure you want to uninstall this plugin ?', mtWarning, [mbYes, mbNo], 0) = mrNo) then exit;
 Screen.Cursor := crHourGlass;
 RT := TRegisterTools.Create;
 Sel := StrToInt(GenList.Selected.SubItems[4]);
 GUID := GPL[Sel].GUID;
 GPL.UnloadAll;
 RT.UninstallPlugIn(GUID);
 FreeAndNil(RT);
 LoadPlugins;
 Screen.Cursor := crDefault;
end;

procedure TForm1.GenListSelectItem(Sender: TObject; Item: TListItem;
  Selected: Boolean);
Var
 I: Integer;
 Node: TTreenode;
 S1, S2: String;
begin
 If Item = nil then exit;
 if not assigned(gpl) then exit;
 TreeGP := GPL.GetPlugInAddr(StrToInt(Item.Subitems[4]));
 Treeview1.items.clear;
 For i := 0 to TreeGP.SensorList.Count - 1 do begin
  Node := Treeview1.Items.Add(nil, TreeGP.SensorList[I].Name);
  Node.HasChildren := true;
 end;
 S1 := TreeGP.Name;
 S2 := IntToStr(TreeGP.Version);
 Statusbar1.Panels[0].Text := 'Name: ' + S1 + ' | Version: ' + S2 + ' | Type: General';
end;

procedure TForm1.TreeView1Expanding(Sender: TObject; Node: TTreeNode;
  var AllowExpansion: Boolean);
Var
 At, I: Integer;
 GenEx: TGenExList;
 S: String;
begin
 GenEx := TGenExList.Create(TreeGP.Plugin);
 At := -1;
 For I := 0 to TreeGP^.SensorList.Count - 1 do begin
  If TreeGP^.SensorList.Sensor[I].Name = Node.Text then At := I;
 end;
 If At = -1 then begin
  MessageDlg('Sensor not found in plugin', mtWarning, [mbOK], 0);
  exit;
 end;
 Node.DeleteChildren;
 For I := 0 to GenEx.ExList[At].Count - 1 do begin
  S := GenEx.ExList[At].ExInfo[I].Name;
  If GenEx.ExList[At].ExInfo[I].EIT = eitRequired then S := S + ' (Required)'
   else S := S + ' (Optional)';
  Treeview1.Items.AddChild(node, S);
 end;
 FreeAndNil(GenEx);
end;

procedure TForm1.PageControlChange(Sender: TObject);
begin
 Case PageControl.ActivePageIndex of
  0: begin
      Statusbar1.SimpleText := 'General Plugins Installed: ' + IntToStr(GenList.Items.Count);
     end;
  1: Begin
      Statusbar1.SimpleText := 'Visual Plugins Installed: ' + IntToStr(VisList.Items.Count);
     end;
  2: begin
      Statusbar1.SimpleText := 'CMLx Plugins Installed: ' + IntToStr(CMLxList.Items.Count);
     end;
 end;
end;

procedure TForm1.Uninstall1Click(Sender: TObject);
Var
 RT: TRegisterTools;
 Sel: Integer;
 GUID: TGUID;
begin
 If Vislist.Selected = nil then exit;
 if (MessageDlg('Are you sure you want to uninstall this plugin ?', mtWarning, [mbYes, mbNo], 0) = mrNo) then exit;
 Screen.Cursor := crHourGlass;
 RT := TRegisterTools.Create;
 Sel := StrToInt(VisList.Selected.SubItems[4]);
 GUID := VPL[Sel].GUID;
 VPL.UnloadAll;
 RT.UninstallPlugIn(GUID);
 FreeAndNil(RT);
 LoadPlugins;
 Screen.Cursor := crDefault;
end;

procedure TForm1.UninstallPlugIn2Click(Sender: TObject);
Var
 RT: TRegisterTools;
 Sel: Integer;
 GUID: TGUID;
begin
 If CMLxlist.Selected = nil then exit;
 if (MessageDlg('Are you sure you want to uninstall this plugin ?', mtWarning, [mbYes, mbNo], 0) = mrNo) then exit;
 Screen.Cursor := crHourGlass;
 RT := TRegisterTools.Create;
 Sel := StrToInt(CMLxList.Selected.SubItems[4]);
 GUID := CPL[Sel].GUID;
 CPL.UnloadAll;
 RT.UninstallPlugIn(GUID);
 FreeAndNil(RT);
 LoadPlugins;
 Screen.Cursor := crDefault;
end;

procedure TForm1.VisListSelectItem(Sender: TObject; Item: TListItem;
  Selected: Boolean);
Var
 Sel, I: Integer;
 VisEx: TVisExList;
 LI: TListItem;
 S1, S2, S: String;
begin
 If Item = nil then exit;
 Listview1.Items.Clear;
 VisEx := Nil;
 Sel := StrToInt(Item.SubItems[4]);
 If Sel < VPL.Count then begin
  Case VPL[Sel].InterfaceVersion of
   1: Begin
       VisEx := TVisExList.Create(VPL[StrToInt(Item.SubItems[4])].PlugIn);
      end;
   2: begin
       VisEx := TVisExList.Create(VPL[StrToInt(Item.SubItems[4])].PlugIn2);
      end;
   3: begin
       VisEx := TVisExList.Create(VPL[StrToInt(Item.SubItems[4])].PlugIn3);
      end;
   4: Begin
       VisEx := TVisExList.Create(VPL[StrToInt(Item.SubItems[4])].PlugIn4);
      End;
  end;
 end;
 If VisEx = nil then exit;
 For I := 0 to VisEx.Count - 1 do begin
  S := VisEx[I].Name;
  If VisEx[I].EIT = eitRequired then S := S + ' (Required)'
   else S := S + ' (Optional)';
  LI := Listview1.Items.Add;
  LI.Caption := S;
 end;
 FreeAndNil(VisEx);
 S1 := VPL[StrToInt(Item.SubItems[4])].Name;
 S2 := IntToStr(VPL[StrToInt(Item.SubItems[4])].Version);
 Statusbar1.Panels[0].Text := 'Name: ' + S1 + ' | Version: ' + S2 + ' | Type: Visual';
end;

procedure TForm1.InstallPlugins1Click(Sender: TObject);
Var
 RT: TRegisterTools;
 RA: TRegisterAs;
 I: Integer;
begin
 If not opendialog1.Execute then exit;
 Screen.Cursor := crHourglass;
 RT := TRegisterTools.Create;
 For I := 0 to Opendialog1.Files.Count - 1 do begin
  RA := raUnknown;
  If Not RT.InstallPlugIn(Opendialog1.Files[I], RA) then begin
   MessageDlg('Unable to install' + #13#10 + Opendialog1.Files[I] + #13#10 + 'Plugin not recognized', mtError, [mbOK], 0);
  end;
 end;
 FreeAndNil(RT);
 LoadPlugins;
 Screen.Cursor := crDefault;
end;

procedure TForm1.About4Click(Sender: TObject);
begin
 form3.execute;
end;

procedure TForm1.TreeView1Collapsed(Sender: TObject; Node: TTreeNode);
begin
 Node.DeleteChildren;
 Node.HasChildren := true;
end;

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
 self.Quit1Click(self);
end;

procedure TForm1.ShowVerboseWindow1Click(Sender: TObject);
begin
 Form4.Show;
 Debug := True;
 Form4.Add('PlugIn Manager - Debug Log', dlcore);
 DebugLevel := dlPlugins;
end;

procedure TForm1.CMLxListSelectItem(Sender: TObject; Item: TListItem;
  Selected: Boolean);
Var
 S1, S2: String;
begin
 S1 := CPL[StrToInt(Item.SubItems[4])].Name;
 S2 := IntToStr(CPL[StrToInt(Item.SubItems[4])].Version);
 Statusbar1.Panels[0].Text := 'Name: ' + S1 + ' | Version: ' + S2 + ' | Type: CMLx';
end;

procedure TForm1.dis83Click(Sender: TObject);
Var
 Reg: TRegistry;
begin
 Dis83.Checked := Not Dis83.Checked;
 Reg := TRegistry.Create;
 Reg.RootKey := HKEY_LOCAL_MACHINE;
 If Reg.OpenKey('\System\CurrentControlSet\Control\Filesystem', false) then begin
  If Dis83.Checked then Reg.WriteInteger('NtfsDisable8dot3NameCreation', 1)
   else Reg.WriteInteger('NtfsDisable8dot3NameCreation', 0);
 end;
 Reg.CloseKey;
 FreeAndNil(Reg);
end;

end.
