IClassFactory2::RequestLicKey

If the fRuntimeKeyAvail field in LICINFO has been returned as TRUE from IClassFactory2::GetLicInfo, then this method creates and returns a license key. The caller can save the license key persistently and use it later in calls to IClassFactory2::CreateInstanceLic.

HRESULT RequestLicKey(
  DWORD dwReserved,  //Unused. Must be zero.
  BSTR* pbstrKey     //Pointer to the license key
);
 

Parameters

dwReserved
[in] Unused. Must be zero.
pbstrKey
[out] Pointer to the caller-allocated BSTR variable that receives the callee-allocated license key on successful return from this method. This parameter is set to NULL on any 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 key was successfully created.
E_NOTIMPL
This class factory does not support run-time license keys.
E_POINTER
The address in pbstrKey is not valid. For example, it may be NULL.
CLASS_E_NOTLICENSED
This class factory supports run-time licensing, but the current machine itself is not licensed. Thus, a run-time key is not available on this machine.

Remarks

The caller can save the license key for subsequent calls to IClassFactory2::CreateInstanceLic to create objects on an otherwise unlicensed machine.

Notes to Callers

The caller must free the BSTR with SysFreeString when the key is no longer needed. The value of fRuntimeKeyAvail is returned through a previous call to IClassFactory2::GetLicInfo.

Notes to Implementers

This method allocates the BSTR key with SysAllocString or SysAllocString[Len], and the caller becomes responsible for this BSTR once this method returns successfully.

This method need not be implemented when a class factory does not support run-time license keys.

QuickInfo

  Windows NT: Use version 4.0 or later.
  Windows: Use Windows 95 or later.
  Windows CE: Unsupported.
  Header: Declared in ocidl.h.

See Also

IClassFactory2::CreateInstanceLic, IClassFactory2::GetLicInfo, LICINFO