Registering Controls and Servers

Before using COM objects, you must register their controls and servers. Most are registered by default. However, if you get a new .ocx, .dll, or other object file for the control or server, you must register the file manually in the Windows® registry.

Use the Windows regsvr32 command to register your file. From the Windows prompt, use the cd function to go to the folder containing the object file. If your object file is an .ocx file, type:

regsvr32 filename.ocx

For example, to register the MATLAB® control mwsamp2.ocx, type:

cd matlabroot\toolbox\matlab\winfun\win32
regsvr32 mwsamp2.ocx

If you encounter problems with this procedure, consult a Windows manual or contact your local system administrator.

Accessing COM Controls Created with .NET

If you create a COM control using Microsoft® .NET Framework 4, use the DOS regasm command with the /codebase option to register your file.

Verifying the Registration

Here are several ways to verify that a control or server is registered. These examples use the MATLAB mwsamp control. Refer to your Microsoft product documentation for information about using Microsoft Visual Studio® or the Microsoft Registry Editor programs.

  • Go to the Visual Studio .NET 2003 Tools menu and execute the ActiveX® control test container. Click Edit, insert a new control, and select MwSamp Control. If you are able to insert the control without any problems, the control is successfully registered. This method only works on controls.

  • Open the Registry Editor by typing regedit at the DOS prompt. Search for your control or server object by selecting Find from the Edit menu. It will likely be in the following structure:

  • Open OLEViewer from the Visual Studio .NET 2003 Tools menu. Look in the following structure for your Control object:

      Object Classes : Grouped by Component Category : Control : 
      Your_Control_Object_Name (i.e. Object Classes : Grouped by 
      Component Category : Control : Mwsamp Control)