检测是否在Windows中注册了OCX类

Sal*_*dor 6 delphi ocx

我需要知道如何检测是否在Windows中注册了OCX类(ClassID)

就像是

function IsClassRegistered(ClassID:string):boolean;
begin
//the magic goes here
end;

begin
  if IsClassRegistered('{26313B07-4199-450B-8342-305BCB7C217F}') then
  // do the work
end;
Run Code Online (Sandbox Code Playgroud)

RRU*_*RUZ 8

您可以检查是否存在CLSIDHKEY_CLASSES_ROOT在Windows注册表中.

检查这个样本

function ExistClassID(const ClassID :string): Boolean;
var
    Reg: TRegistry;
begin
 try
     Reg := TRegistry.Create;
   try
     Reg.RootKey := HKEY_CLASSES_ROOT;
     Result      := Reg.KeyExists(Format('CLSID\%s',[ClassID]));
   finally
     Reg.Free;
   end;
 except
    Result := False;
 end;
end;
Run Code Online (Sandbox Code Playgroud)