interfaces - List custom interfaces to COM server

Syntax

C = h.interfaces
C = interfaces(h)

Description

C = h.interfaces returns cell array of strings C listing all custom interfaces implemented by the component in a specific COM server. The server is designated by input argument, h, which is the handle returned by the actxcontrol or actxserver function when creating that server.

C = interfaces(h) is an alternate syntax for the same operation.

Examples

Once you have created a COM server, you can query the server component to see if any custom interfaces are implemented. Use the interfaces function to return a list of all available custom interfaces:

h = actxserver('mytestenv.calculator') 
h =
   COM.mytestenv.calculator

customlist = h.interfaces
customlist =
   ICalc1
   ICalc2
   ICalc3

To get a handle to the custom interface you want, use the invoke function, specifying the handle returned by actxcontrol or actxserver and also the name of the custom interface:

c1 = h.invoke('ICalc1')
c1 =
   Interface.Calc_1.0_Type_Library.ICalc_Interface

You can now use this handle with most of the COM client functions to access the properties and methods of the object through the selected custom interface. For example, to list the properties available through the ICalc1 interface, use

c1.get
     background: 'Blue'
         height: 10
          width: 0

To list the methods, use

c1.invoke
   Add = double Add(handle, double, double)
   Divide = double Divide(handle, double, double)
   Multiply = double Multiply(handle, double, double)
   Subtract = double Subtract(handle, double, double)

Add and multiply numbers using the Add and Multiply methods of the custom object c1:

sum = c1.Add(4, 7)
sum =
    11

prod = c1.Multiply(4, 7)
prod =
    28

See Also

actxcontrol, actxserver, invoke, get (COM)

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS