Document-ID:        39818.1
Subject:            Registering and Deploying OCX Controls on Windows 95
Author:             DBOOTH
Last Modified:      06 Nov 96 


1. Introduction
===============
This bulletin explains the procedure for registering an OCX control on a PC 
running Microsoft Windows 95.  It also describes the procedure for deploying an 
OCX control with an application onto a runtime PC.

2. What is an OCX control?
==========================
An OCX control (also known as an ActiveX control) is a small OLE server 
application which can be entirely embedded into an application with OLE client 
capabilities.  

An OCX control is typically used to enhance the client application by providing 
some additional, self-contained functionality, usually with a graphical 
interface.  

OCX controls possess properties (physical and logical characteristics) and 
methods (actions which the control can perform).  An OLE client application 
communicates with an OCX control by reading and writing values to and from its 
properties and by invoking its methods.  An OCX control can also generate 
events in response to specific changes in its status.   These events can be 
intercepted by the OLE client application and acted upon.  

Examples of OLE controls are a tabbed property sheet, a spin control and a 
calendar control.

Some development tools (e.g Microsoft Visual Basic, Oracle Power Objects) 
support the importing of  OCX controls onto their tool palette.  Importing an 
OCX control creates an additional icon on the tool palette to provide rapid 
access to the OCX control when developing applications.

3. How do I register an OCX control?
====================================
Before an OCX control can be used it must be registered in the Windows 95 
system registry to advertise its availability to OLE client applications.
If you install an OCX control using an installation program supplied with the 
OCX control there should be nothing you need to do to register the control as 
this should be handled by the installation program.   If you need to manually 
register an OCX control you must use a utility called REGSVR32 which registers 
OCX controls and OLE automation servers.  The syntax for running REGSVR32 is as 
follows:

REGSVR32 [/u] [/s] filename

Where:

/u is an optional switch used to unregister an OCX control.

/s is an optional switch to suppress screen messages (usually used by 
installation programs when registering OCX controls).

filename is the name of the .OCX file being registered.  This file must either 
exist in the WINDOWS\SYSTEM or WINDOWS folders , a folder on the DLL search 
path or be fully qualified with a folder name.

4. How do I obtain REGSVR32?
============================
REGSVR32.EXE is not supplied with Microsoft Windows 95 itself. REGSVR32.EXE is 
supplied with Microsoft Visual C++.  It is also supplied with packages that 
contain bundled OCX controls (e.g Visual Basic V4, Oracle Power Objects V2) and 
packages supplied by OCX control vendors.

5. What happens when an OCX control is registered?
==================================================
When REGSVR32 is used to register an OCX control, information about the OCX 
control is entered into the Windows 95 registry.  

A registry key is created under the HKEY_LOCAL_MACHINE\SOFTWARE\Classes key.  
This new registry key is uniquely named after the OLE class identifier and is 
assigned a default value describing the OCX .  For example:

Key Name                               Value
-------------------------------------  -----------------------------
CSSPIN.CSSpinCtrl.1                    "Crescent Spin Control"

Under this new registry key a subkey called CLSID is created and assigned a 
unique internal OLE class identifier 

e.g {EAF26C8F-9586-101B-9306-0020AF234C9D}.

A registry key is also created under HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID. 
 This new registry key is uniquely named with the unique internal OLE class 
identifier and is also assigned a default value describing  the OCX .  For 
example:

Key Name                                Value
--------------------------------------  -----------------------
{EAF26C8F-9586-101B-9306-0020AF234C9D}  "Crescent Spin Control"

Under this new registry key, a number of subkeys are created to provide further 
information about the OCX.  The exact subkeys vary from one OCX to another but 
the most common are:

InProcServer32 - The name and location of the .OCX file.  If no location is 
given, it is assumed to be in WINDOWS\SYSTEM, WINDOWS or a folder on the DLL 
search path.  e.g. "D:\ORAWIN95\OPO20\OCX\CSSPIN32.OCX"

ProgID - The descriptive OLE class identifier e.g. "CSSPIN.CSSpinCtrl.1"

ToolboxBitmap32 - The name and location of a file containing the icon to be 
used when the OCX is imported to a tool palette.  An icon number within the 
file is also included.  e.g. "D:\ORAWIN95\OPO20\OCX\CSSPIN32.OCX, 1"

Version - The version number of the OCX. e.g "4.0"

6. What can go wrong with an OCX control?
=========================================
An OCX control may behave in an unexpected way, raise unexpected errors or 
simply not appear at all in your application.  These problems could be caused 
by the OCX control not being registered correctly on the PC.  To resolve this 
problem you simply need to run the REGSVR32 utility to register the OCX.

If the OCX has already been registered, the problem may be caused by a 
supporting DLL not being accessible.  If you are unsure what supporting DLLs an 
OCX control requires you can use a utility such as Quikview (supplied on the 
Windows 95 CD-ROM but not installed by a typical install) to read the image 
file header of the .OCX file.  This will show an Import table listing the DLLs 
called by the OCX.  Once you have this list of DLLs you can ensure that they 
are located in the WINDOWS\SYSTEM folder, the WINDOWS  folder or a folder on 
the DLL search path.

MFC40.DLL and MSVCRT40.DLL are two supporting DLLs frequently used by OCX 
controls developed with Microsoft Visual C++ and the Microsoft Foundation Class 
libraries.

7. How do I deploy an OCX control to a runtime PC?
==================================================
If you wish to deploy an application which uses an OCX control to a runtime PC, 
 you will also need to deploy the OCX control itself.

Firstly, determine whether the license you have with the OCX control supplier 
allows you to distribute the OCX control to runtime PCs free of charge or 
whether an additional license will be required.  If you are using a third party 
OCX control bundled with an application development tool  (e.g Microsoft Visual 
Basic or Oracle Power Objects V2), it is important to check whether the 
conditions of use of the OCX control allow you to deploy the OCX to runtime PCs 
free of charge as the license may only permit you
to use the OCX for development purposes.

Copy the .OCX file itself and any supporting DLL files to the runtime machine.  
The .OCX file may be copied to any folder on the runtime machine.  The 
supporting DLLs should be copied to the WINDOWS\SYSTEM folder, the WINDOWS 
folder or a folder on the DLL search path.

Finally, obtain a copy of the REGSVR32 utility and use this to register the OCX 
control on the runtime PC as described earlier.