Package com.ms.com Previous
Previous
Contents
Contents
Index
Index
Next
Next

Interface ILicenseMgr

Methods

public interface ILicenseMgr extends IUnknown {
  // Methods
  public void setPackage(String url);
  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);
}

The ILicenseMgr interface supports use of licensed Component Object Module (COM) components or controls from your Java application.

A licensed control cannot be instantiated except by legal users. A design-time license allows you to embed the control in your applications. When you distribute the application, a run-time license allows the control to be instantiated when you run the application.

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

To use ILicenseMgr 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 ILicenseMgr when using DAO.


Methods

For compatibility with version 1.0, the methods described here instantiate all COM objects on the process main apartment thread. Because of the significant thread-switching overhead in this case, these methods should not be used unless the object requires licensing information.

setPackage

public void setPackage(String url);

Sets the package.

Return Value:

No return value.

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


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 being created as part of an aggregate). Otherwise, this value should be null.
ctxFlags The ComContext value representing the context that the new object should be created in.


createInstance

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

Creates an instance of the specified COM class.

Return Value:

Returns an instance of the specified COM class.

ParameterDescription
clsid The class identifier of the COM class to be instantiated, specified in string form (for example, "{00025E15-0000-0000-C000-000000000046}").
punkOuter The aggregating object (if the object is being created as part of an aggregate). Otherwise, this value should be null.
ctxFlags The ComContext value representing the context that the new object should be created in.

Remarks:

Warning In general, this method should not be called. The appropriate means of creating an instance of a COM class is to use the new operator on the Java wrapper generated by the Java Type Library Wizard (or JavaTLB). This method should be called only in special situations and only if you are familiar with low-level COM programming.

Throws:

ComFailException if there was an error.


createWithLic

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

Creates a new instance of the specified, 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 of the COM class to be instantiated, specified in string form (for example, "{00025E15-0000-0000-C000-000000000046}").
punkOuter The aggregating object (if the object is being created as part of an aggregate). Otherwise, this value should be null.
ctxFlags The value representing the context that the new object is created in.

Throws:

ComFailException if there was an error.

Example:

The following is a helper class with single method, create, that wraps a call to CreateWithLic. By using this method, you can create an instance of a specific licensed component without having to specify the license or the Class identifier (CLSID) every time.

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,								      // IUnknown* punkOuter 
            ComContext.INPROC_SERVER                  // ComContext ctxFlags
			);
		return result;
	}
}


Top© 1997 Microsoft Corporation. All rights reserved. Legal Notices.