Delphi

[Delphi] 설치된 ActiveX 리스트 불러오기

그저심 2022. 5. 14. 17:46
procedure TForm1.GetActiveXObjects(List: TStringList);
procedure KeyNotFound;
  begin
    raise exception.create('Key not found.');
  end;
const
  PATH = 'Software\\Classes\\TypeLib\\';
var
  R: TRegistry;
  S1, S2: TStringList;
  S, Output: String;
begin
  List.Clear;
  try
    S1 := TStringList.Create;
    S2 := TStringList.Create;
    R := TRegistry.create(KEY_READ);
    R.RootKey := HKEY_LOCAL_MACHINE;

    if (not R.OpenKey(PATH, False)) then
      KeyNotFound;
    R.GetKeyNames(S1);
    for S in S1 do begin
      // Position: CLSID
      R.CloseKey;
      if (not R.OpenKeyReadOnly(PATH + S + '\\')) then
        Continue;
      R.GetKeyNames(S2);
      // Position:Version
      if (S2.Text = '') or (not R.OpenKeyReadOnly(S2.Strings[0])) then
        Continue;
      Output := R.ReadString('');
      if Output <> '' then
        List.Add(Output);
    end;

  finally
    R.Free;
    S1.Free;
    S2.Free;
  end;
end;
반응형