unit InsertFormUnit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, registry, StdCtrls, Buttons, ExtCtrls;

type
  TInsertOLEForm = class(TForm)
    Panel1: TPanel;
    OLEItemsListBox: TListBox;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    ProgramsID:TStrings;
  end;

var
  InsertOLEForm: TInsertOLEForm;

implementation

{$R *.dfm}

procedure TInsertOLEForm.FormShow(Sender: TObject);
var
 i:Integer;
 CLSID:String;
 Keys:TStrings;
 reg:TRegistry;
begin
 Keys:=TStringList.Create;
 ProgramsID.Clear;
 OLEItemsListBox.Items.Clear;

 reg:=TRegistry.Create;
 reg.RootKey:=HKEY_CLASSES_ROOT;
 reg.OpenKey('\', false);
 reg.GetKeyNames(Keys);

 for i:=0 to Keys.Count-1 do
  begin
   reg.CloseKey;
   reg.OpenKey(Keys.Strings[i], false);
   if not reg.KeyExists('Insertable') then continue;
   OLEItemsListBox.Items.Add(reg.ReadString(''));
   reg.OpenKey('CLSID', false);
   CLSID:=reg.ReadString('');
   reg.CloseKey;
   if reg.OpenKey('CLSID\'+CLSID, false) then
    begin
     if reg.OpenKey('ProgId', false) then
      ProgramsID.Add(reg.ReadString(''))
     else
      ProgramsID.Add('[Нет идентификатора программы]')
    end;
  end;
 Keys.Free;
end;

procedure TInsertOLEForm.FormCreate(Sender: TObject);
begin
 ProgramsID:=TStringList.Create;
end;

procedure TInsertOLEForm.FormDestroy(Sender: TObject);
begin
 ProgramsID.Free;
end;

end.
