次の方法で共有


IClassFactory2 (Compact 2013)

3/26/2014

This interface enables a class factory object, in any object server, to control object creation through licensing.

This interface is an extension to IClassFactory. This extension enables a class factory executing on a licensed machine to provide a license key that can be used later to create an object instance on an unlicensed machine.

Such considerations are important for objects like controls that are used to build applications on a licensed machine.

Subsequently, the application built must be able to run on an unlicensed machine.

The license key gives only that one client application the right to instantiate objects through IClassFactory2 when a full machine license does not exist.

This interface is not marshaled by the OS. You can marshal this interface by writing your own marshaling code.

When to Implement

Implement this interface on a class factory object to control object creation through a license.

A class that supports licensing should be marked in an object's type information with the [licensed] attribute on the object's coclass entry.

The CreateInstance method inherited from IClassFactory is allowed to return CLASS_E_NOTLICENSED to indicate that object creation is controlled through licensing.

The caller can create an instance of this object only through IClassFactory2::CreateInstanceLic if the caller has a license key obtained from IClassFactory2::RequestLicKey.

Otherwise, no object creation is allowed.

When to Use

Use this interface to create licensed objects or to obtain a license key that can be used in later creations.

Methods in Vtable Order

IUnknown method

Description

QueryInterface

Returns pointers to supported interfaces.

AddRef

Increments the reference count.

Release

Decrements the reference count.

IClassFactory method

Description

CreateInstance

Creates an uninitialized object.

LockServer

Locks object application open in memory.

IClassFactory2 method

Description

GetLicInfo

Fills a LICINFO structure with information on the licensing capabilities of this class factory.

RequestLicKey

Creates and returns a license key that the caller can save and use later in calls to IClassFactory2::CreateInstanceLic.

CreateInstanceLic

Creates an instance of the licensed object given a license key from IClassFactory2::RequestLicKey.

Remarks

To determine whether the platform supports this interface, see Determining Supported COM APIs.

Requirements

Header

ocidl.h,
ocidl.idl

Library

ole32.lib,
uuid.lib

See Also

Reference

COM Interfaces
IClassFactory