# IClassFactory2::CreateInstanceLic

Creates an instance of the object class supported by this class factory, given a license key previously obtained from IClassFactory2::RequestLicKey. This method is the only possible means to create an object on an otherwise unlicensed machine.

HRESULT CreateInstanceLic(

IUnknown* pUnkOuter , | //Pointer to controlling unknown of aggregated object
IUnknown* pUnkReserved , | //Unused. Must be NULL.
REFIID riid , | //Reference to the identifier of the interface
BSTR bstrKey , | //License key provided by IClassFactory2::RequestLicKey
void** ppvObject | //Indirect pointer to the interface of the type specified in riid
); |

Parameters

pUnkOuter
  [in] Pointer to the controlling IUnknown interface on the outer unknown if this object is being created as part of an aggregate. If the object is not part of an aggregate, this parameter must be NULL.
pUnkReserved
  [in] Unused. Must be NULL.
riid
  [in] Reference to the identifier of the interface to be used to communicate with the newly created object.
bstrKey
  [in] Run-time license key previously obtained from IClassFactory2::RequestLicKey that is required to create an object.
ppvObject
  [out] Indirect pointer to the interface of the type specified in riid. This parameter is set to NULL on failure.

Return Values

This method supports the standard return values E_INVALIDARG, E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following:

S_OK
  The license was successfully created.
E_NOTIMPL
  This method is not implemented because objects can only be created on fully licensed machines through IClassFactory::CreateInstance.
E_POINTER
  The pointers passed in bstrKey or ppvObject are not valid. For example, it may be NULL.
E_NOINTERFACE
  The object can be created (and the license key is valid) except the object does not support the interface specified by riid.
CLASS_E_NOAGGREGATION
  The pUnkOuter parameter is non-NULL, but this object class does not support aggregation.
CLASS_E_NOTLICENSED
  The key provided in bstrKey is not a valid license key.

Remarks

#### Notes to Implementers

If the class factory does not provide a license key (that is, IClassFactory2::RequestLicKey returns E_NOTIMPL and the fRuntimeKeyAvail field in LICINFO is set to FALSE in IClassFactory2::GetLicInfo), then this method can also return E_NOTIMPL. In such cases, the class factory is implementing IClassFactory2 simply to specify whether or not the machine is licensed at all through the fLicVerified field of LICINFO.

See Also

IClassFactory2::GetLicInfo, IClassFactory2::RequestLicKey, LICINFO