Getting Started with COM

Creating an Instance of a COM Object

Two MATLAB® functions enable you to create COM objects:

  • actxcontrol — Creates an instance of a control in a MATLAB figure.

  • actxserver — Creates and manipulates objects from MATLAB that are exposed in an application that supports Automation.

Each function returns a handle to the object's main interface, which you use to access the object's methods, properties, and events, and any other interfaces it provides.

Getting Information About a Particular COM Control

In general, you can determine what you can do with an object using the methods, get, and events functions.

Information about Methods

To list the methods supported by the object handle, type:


Information about Properties

To list the properties of the object handle, type:


To see the value of the property PropertyName, type:


Use the set function to change a property value.

Information about Events

To list the events supported by the object handle, type:


Getting an Object's ProgID

To get the programmatic identifier (ProgID) of a COM control that is already registered on your computer, use the actxcontrollist command. You can also use the ActiveX Control Selector, displayed with the command actxcontrolselect. This interface lets you see instances of the controls installed on your computer.

Registering a Custom Control

If your MATLAB program uses a custom control (e.g., one that you have created especially for your application), you must register it with the Microsoft® Windows® operating system before you can use it. You can do this from your MATLAB program by issuing an operating system command:

!regsvr32 /s filename.ocx

where filename is the name of the file containing the control. Using this command in your program enables you to provide custom-made controls that you make available to other users by registering the control on their computer when they run your MATLAB program. You might also want to supply versions of a Microsoft ActiveX® control to ensure that all users have the same version.

See Also

| | | | | | |

Related Examples

More About