How to deploy an external ActiveX control with your LANSA Application

Date:4 April 2005
Product/Release:Visual LANSA V10 and above
Abstract:Using Post Installation Commands to register ActiveX controls after application installation
Submitted By:LANSA Technical Support
Last Review:November 2010

When creating a LANSA application, sometimes you may require functionality that can only be provided by a 3rd-party ActiveX control. Visual LANSA supports all standard ActiveX Interfaces so there are a wealth of controls to choose from, from calendar drop-downs, to Microsoft Word or Outlook integration.

Some of these controls have comprehensive installation programs to automatically register themselves on your PC (i.e. Microsoft Office ActiveX controls require Office to be installed on the target PC), however others are supplied as single .DLL or.OCX files. Shipping the DLLs only with your application means your distributable package can be much smaller, however it can add complexity to the installation procedure - You must ask your users to manually install the ActiveX control as well as your application.

If the ActiveX control can be distributed as a single DLL, you can use Post Installation Commands to automatically register the control for you. In the following example, we will be distributing the Richtx32.OCX control with our application:

  1. Create the following batch file:
    Move Richtx32.OCX %windir%\System32\
    Regsvr32 %windir%\System32\Richtx32.OCX
    • You can call it Richtx32.BAT
    • Note that the first line of the batch file simply moves the Richtx32.OCX to the Windows System32 directory (using standard Windows Environment Variables)
    • The second line registers the ActiveX using Regsvr32.exe
    • You can test the batch file on your own PC by placing the DLL/OCX in the same directory as the Batch file, then executing it
  2. Create your deployment package using the options relevant to your application (this may vary from application to application so please consult the Deployment Tool documentation for more information)
  3. Add the LANSA Forms, Files, Fields etc. to the package. If you select Components and Cascade Selection in the Cross Reference settings, the ActiveX component should get included in the package, however it might be a good idea to manually select it from the list of components
  4. Now add Other Objects - Non-LANSA objects. Browse to and select the following:
    • RICHTX32.OCX (this will most likely be in your Windows\System32 directory)
    • RICHTX32.BAT (which you created in step 1)

  5. Go to Installation Path Definitions on The Other Object screen
  6. Create a new Path definition called TEMPDIR as 'Temp Directory'
  7. Select this directory for both objects
  8. Under Commands, go to Post Installation Commands and add the following command:

    Commands to execute

    Note that we are not deleting Richtx32.bat. This can be done in a separate post-installation command if needed
  9. Save, Build then Release your package

Note: Please ensure that you abide by the licensing agreement of the ActiveX control you are distributing. Some controls require specific licenses if you want to distribute them with your application.