Packages
 In this topic

*Methods

 

Packages   PreviousThis PackageNext
Package com.ms.com   Previous This
Package
Next

 


Interface ILicenseMgr

public interface ILicenseMgr extends IUnknown
{
  // Methods
  public IUnknown createFromPackage(int index, IUnknown punkOuter,
        int ctxFlags);
  public IUnknown createInstance(String clsid, IUnknown punkOuter,
        int ctxFlags);
  public IUnknown createWithLic(String lic, String clsid,
        IUnknown punkOuter, int ctxFlags);
  public void setPackage(String url);
}

This interface supports the use of licensed Component Object Model (COM) components or controls in a Java application. A licensed control cannot be instantiated except by legal users. Using a design-time license, however, enables you to embed the control in your applications. When you distribute the application, a run-time license allows the control to be instantiated when the application is run.

An HTML page containing licensed controls must include an associated license package (.lpk) file, which stores the run-time control licenses. Use the License Package Authoring Tool (lpk_tool.exe) included with the Microsoft® ActiveX® SDK to create a .lpk file. For further information on the ActiveX licensing scheme, refer to the ActiveX SDK.

To use the ILicenseMgr class with a licensed control, call the createWithLic method and specify the license string explicitly to create an instance of the control.

An example of a licensed component is the _DBEngine component in Data Access Objects (DAO). You must use the ILicenseMgr class when you use DAO.

Note For compatibility with the Microsoft SDK for Java 1.0, the following methods instantiate all COM objects on the main apartment thread of the process. Because of the significant thread-switching overhead, these methods should not be used unless the object requires licensing information.

IUnknown
  |
  +--ILicenseMgr

Methods

createFromPackage

public IUnknown createFromPackage(int index, IUnknown punkOuter,
        int ctxFlags);

Creates a package.

Return Value:

Returns the new package.

ParameterDescription
index The index of the package.
punkOuter The aggregating object if the object is created as part of an aggregate; otherwise, null.
ctxFlags The ComContext value that represents the context that the new object is created in.

createInstance

public IUnknown createInstance(String clsid, IUnknown punkOuter,
        int ctxFlags);

Creates an instance of the specified COM class.

Warning In general, this method should not be called. The best way to create an instance of a COM class is to use the new operator on the Java wrapper generated by the jactivex tool.

Return Value:

Returns an instance of the specified COM class.

ParameterDescription
clsid The class identifier (CLSID) of the instantiated COM class.
punkOuter The aggregating object if the object is being created as part of an aggregate; otherwise, null.
ctxFlags The ComContext value that represents the context that the new object is created in.

Exceptions:

com.ms.com.ComFailException if there is an error instantiating the class.

createWithLic

public IUnknown createWithLic(String lic, String clsid, IUnknown punkOuter,
        int ctxFlags);

Creates a new instance of a licensed COM class.

Return Value:

Returns a new instance of the specified licensed COM class.

ParameterDescription
lic The license for the COM class that is instantiated.
clsid The class identifier (CLSID) of the instantiated COM class.
punkOuter The aggregating object if the object is being created as part of an aggregate; otherwise, null.
ctxFlags The value that represents the context that the new object is created in.

Remarks:

The following example shows a helper class with a single method called create that wraps a call to createWithLic. Using this method, you can create an instance of the _DBEngine licensed component without having to specify the license or the class identifier (CLSID).

import dao3032.*;
import com.ms.com.*;
public class dao_dbengine

{
  static public _DBEngine create()
  {
  _DBEngine result;
  ILicenseMgr mgr = new LicenseMgr();
  result = (_DBEngine) mgr.createWithLic(
  "mjgcqcejfchcijecpdhckcdjqigdejfccjri",   // BSTR lic
  "{00025E15-0000-0000-C000-000000000046}", // BSTR clsid, 
     null,ComContext.INPROC_SERVER); // IUnknown* punkOuter, 
                                     // ComContext ctxFlags
	 return result;
	 }
}

Exceptions:

com.ms.com.ComFailException if there is an error instantiating the class.

setPackage

public void setPackage(String url);

Sets the package specified by the URL.

Return Value:

No return value.

ParameterDescription
url The Uniform Resource Locator (URL) of the package.

upnrm.gif © 1998 Microsoft Corporation. All rights reserved. Terms of use.