主要内容

本页采用了机器翻译。点击此处可查看最新英文版本。

获取注册表信息

当使用 COM 组件进行编程时,您可能需要有关组件的详细资料。您可以使用 componentinfo(一个 MATLAB® 函数)来查询系统注册表以获取有关任何已安装组件的详细信息。

此示例在注册表中查询名为 mycomponent 且版本为 1.0 的组件。该组件有四种方法:mysumrandvectorsgetdatesmyprimes;两个属性:mn;以及一个事件:myevent

Info = componentinfo('mycomponent', 1, 0)

Info = 

       Name: 'mycomponent'
      TypeLib: 'mycomponent 1.0 Type Library'
        LIBID: '{3A14AB34-44BE-11D5-B155-00D0B7BA7544}'
    MajorRev: 1
    MinorRev: 0
    FileName: 'D:\Work\ mycomponent\distrib\mycomponent_1_0.dll'
    Interfaces: [1x1 struct]
    CoClasses: [1x1 struct]

Info.Interfaces

ans = 

      Name: 'Imyclass'
       IID: '{3A14AB36-44BE-11D5-B155-00D0B7BA7544}'

Info.CoClasses

ans = 

          Name: 'myclass'
         CLSID: '{3A14AB35-44BE-11D5-B155-00D0B7BA7544}'
         ProgID: 'mycomponent.myclass.1_0'
   VerIndProgID: 'mycomponent.myclass'
InprocServer32:'D:\Work\mycomponent\distrib\mycomponent_1_0.dll'
       Methods: [1x4 struct]
    Properties: {'m', 'n'}
        Events: [1x1 struct]

Info.CoClasses.Events.M

ans =

function myevent(x, y)

Info.CoClasses.Methods

ans = 

1x4 struct array with fields:
    IDL
    M
    C
    VB

Info.CoClasses.Methods.M

ans =

function [y] = mysum(varargin)

ans =

function [varargout] = randvectors()

ans =

function [x] = getdates(n, inc)

ans =

function [p] = myprimes(n)

返回的结构包含与组件的注册表和类型库中的最重要信息相对应的字段。