Contents

Deploy ActiveX Controls Requiring Run-Time Licenses

When you deploy a Microsoft® ActiveX® control that requires a run-time license, you must include a license key, which the control reads at run-time. If the key matches the control's own version of the license key, an instance of the control is created. Use the following procedure to deploy a run-time-licensed control with a MATLAB® application.

Create a Function to Build the Control

First, create a function to build the control and save is as a .m file. The file must contain two elements:

  • The pragma %#function actxlicense. This pragma causes the MATLAB Compiler™ to embed a function named actxlicense into the standalone executable file you build.

  • A call to actxcontrol to create an instance of the control.

Place this file in a folder outside of the MATLAB code tree.

Here is an example file:

function buildcontrol
%#function actxlicense
h=actxcontrol('MFCCONTROL2.MFCControl2Ctrl.1',[10 10 200 200]);

Build the Control and the License File

Change to the folder where you placed the function you created to build the control. Call the function. When it executes this function, MATLAB determines whether the control requires a run-time license. If it does, MATLAB creates another file, named actxlicense.m, in the current working folder. The actxlicense function defined in this file provides the license key to MATLAB at run-time.

Build the Executable

Next, call MATLAB Compiler to create the standalone executable from the file you created to build the control. The executable contains both the function that builds the control and the actxlicense function.

mcc -m buildcontrol

Deploy the Files

Finally, distribute buildcontrol.exe, buildcontrol.ctf, and the control (.ocx or .dll).

Was this topic helpful?