How do I register a file in Windows in order to set up an ActiveX communication?

5 views (last 30 days)
I receive an error when I try to start an ActiveX control or server from MATLAB. The error occurs because the control or server is not registered in the Windows registry.
For example, if the mwsamp.ocx file is not registered, I get the following error:
mwsamp
Warning: Control creation failed: (MWSAMP.MwsampCtrl.1)
??? Error using ==> activex/activex
Invalid ActiveX object
Error in ==> D:\Applications\matlab\toolbox\matlab\winfun\actxcontrol.m
On line 30 ==>
Error in ==> D:\Applications\matlab\toolbox\matlab\winfun\mwsamp.m
On line 20 ==> h = actxcontrol('MWSAMP.MwsampCtrl.1', [0 0 200 200], f, 'sampev')

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
Most of the controls and servers are registered by default. However, if you get a new .ocx, .dll, or other object file and want to load it into a MATLAB figure window, you must first register the file.
The DOS regsvr command will register an object file, such as an ocx file, into the Windows registry.
The following is an example on how to register an OCX file:
From the DOS prompt, cd to the directory where the OCX file is located and type:
regsvr32 mwsamp.ocx
This should register the OCX file. If you encounter problems with this command, please consult a Windows manual or contact your local system administrator.
To check if the control or server is registered, you can look at the registry. Use OLEVIEW.EXE or the MSVC Tool: ActiveX control test container program (see below).
Directions for checking if an ActiveX control is registered using the MwSamp example:
1. Check to see if mwsamp is registered and loaded properly. Here are 3 ways to check this:
A) Go to MSVC 6.0 tools menu, execute ActiveX control test container, click Edit, insert new control and select MwSamp Control.
If you can insert the control without any problem, the control is registered.
B) Open the Registry Editor by typing 'regedit' at the DOS prompt. You can search for your control object by going to the EDIT menu and Find.
It will likely be in the following structure: HKEY_CLASSES_ROOT/file_name
3) Open the OLEViewer form the MSVC 6.0 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)
2. If you are still getting an error after registering the control, try registering a Microsoft control to make sure the problem isn't with your control.

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!