Licensing for ActiveX Components

There are 2 types of licensing schemes for ActiveX controls.

1.Design time – implemented using LIC Files.
2.Run time – implemented using LPK (License Package File) files.

If you are using licensed ActiveX control for the development purposes then you would need LIC file to load it in the development environment like Visual Studio or MS Access etc. And if you are using it in the web application then you would need LPK file to run it in the web browser like IE etc.

In every ActiveX control licensing is implemented by implementing methods of IClassFactory2 interface, which is built upon IClassFactory interface. These interfaces provide methods that are used for verifying licensing information during the instantiations of the control both in the design time as well as run time. Some of the methods are: GetLicInfo, RequestLicKey, andCreateInstanceLic etc.

Design-Time Licensing:

In the design environments like Visual Studio or MS Access etc, when you try to place ActiveX control on the form or web page or create instance of the control, one or more of these methods are called to verify the licensing information from the license file (.Lic file) and upon verification the control is instantiated.

Run-Time Licensing:

Run time licensing differs for execution environments like Visual Studio or MS Access etc and Internet Explorer. In case of VS, license keys of the ActiveX controls used in the application are embedded in the executable file (.exe file) of the application whereas for Internet Explorer license keys of ActiveX control are stored in the license package file(.Lpk file).

In case of Visual Studio or MS Access, run time licensing is almost same as design time licensing. During the execution of application licensing information embedded in the exe file is verified by one or more methods of IClassFactory2 interface against the licensing information stored in the controls used in the application.

In case of Internet Explorer, licensing scenario is bit different specially when you are distributing ActiveX control (see my earlier post on How to redistribute ActiveX control with Web Application
) due to following reasons:

1.ActiveX control is executed in the remote client machine where as the host application exists in the server machine.
2.Due to the openness of the delivered HTML source code, licensing information can not be embedded in the server response.

So, due to the above scenario, run time licensing is implemented with a new file called the license package file (or LPK file). This file can be included in any HTML page by using the object tag.
Example:

< OBJECT CLASSID="clsid:5220cb21-c88d-11cf-b347-00aa00a28331" >
< PARAM NAME="LPKPath" VALUE="LPKfilename.LPK" >
< /OBJECT >

Note- CLASSID is the class ID of ActiveX License Manager component.

The above mentioned object tag embeds ActiveX License Manager, which is a component of Internet Explorer 4.0 found in the Licmgr10.dll file. This component parses an .lpk file and extracts the license key for each corresponding CLSID in the file. Remember, this tag should be added before the codebase tag for the control distribution.
At run time, when Internet Explorer 4.0 is rendering an HTML page that contains ActiveX Controls, the License Manager calls the IClassFactory2::CreateInstanceLic method, passing the license key that it extracted from the .lpk file in order to verify that a control is licensed. If the license key matches the control's license, the control will be rendered on the page.
Note: - LPK file should exists at the root of the application in the hosting server. Although you can add multiple lpk files in the web page but only first one will be considered by IE. Licensing information of all the licensed controls used in a page should be added in a lpk file embedded in that page.

Create license package file (.lpk file):
LPK file can be created using a utility named License Package Authoring Tool (Lpk_Tool.exe) that can be downloaded from the download section of this blog.
The application is actually simple to use. When you start the application, it displays a combo box that lists all of the ActiveX Controls currently running on your computer. The next step requires that you choose the controls that you want to display on a given HTML page. You choose a control by highlighting it in the combo box and then clicking the Add button. Once you've selected all the controls that you want to display on a given page, you can create and save the actual .lpk file by clicking the Save & Exit button.

References:

http://msdn.microsoft.com/en-us/library/aa231198(VS.60).aspx
http://msdn.microsoft.com/en-us/library/aa751973(VS.85).aspx

No comments: