> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XStoreRegisterPackageLicenseLost

> XStoreRegisterPackageLicenseLost

# XStoreRegisterPackageLicenseLost

Registers a callback for the license lost event.
Use this API to register Durable licenses acquired through [XStoreAcquireLicenseForPackageAsync](/reference/system/xstore/functions/xstoreacquirelicenseforpackageasync) and [XStoreAcquireLicenseForDurablesAsync](/reference/system/xstore/functions/xstoreacquirelicensefordurablesasync).

## Syntax

```cpp theme={null}
HRESULT XStoreRegisterPackageLicenseLost(  
         XStoreLicenseHandle licenseHandle,  
         XTaskQueueHandle queue,  
         void* context,  
         XStorePackageLicenseLostCallback* callback,  
         XTaskQueueRegistrationToken* token  
)  
```

### Parameters

*licenseHandle*   \_In\_\
Type: XStoreLicenseHandle

The license handle to register the callback for.

*queue*   \_In\_\
Type: XTaskQueueHandle

Async queue to handle asynchronous work.

*context*   \_In\_opt\_\
Type: void\*

Title defined  context to pass to the callback.

*callback*   \_In\_\
Type: XStorePackageLicenseLostCallback\*

The callback to register.

*token*   \_Out\_\
Type: [XTaskQueueRegistrationToken\*](/reference/system/xtaskqueue/structs/xtaskqueueregistrationtoken)

On success contains a token used to identify the callback.

### Return value

Type: HRESULT

HRESULT success or error code.

## Remarks

This function registers the callback function defined by [XStorePackageLicenseLostCallback](/reference/system/xstore/functions/xstorepackagelicenselostcallback).
The registered callback function is called when the next Durable license lost event occurs.
The callback function isn't called during registration.
A license lost event often occurs when the purchasing account signs out of the device and their previously shared license isn't available to the current user.
To avoid a memory leak, you must call [XStoreUnregisterPackageLicenseLost](/reference/system/xstore/functions/xstoreunregisterpackagelicenselost) when you're finished with the callback function.

A Durable license can be lost at any time due to a user change, network change, concurrency check, or the license expiring on the device.
A game should register for license lost events and attempt to reacquire the license for the Durable when the callback triggers.
License lost events can help detect when the system erroneously returns a cached license to the current player that belongs to another account.
In such cases, a license lost event immediately fires and when XStoreAcquireLicense\* is called again, a fresh license is provided.

For a usage example, see [XStoreAcquireLicenseForPackageAsync](/reference/system/xstore/functions/xstoreacquirelicenseforpackageasync).

## Requirements

**Header:** XStore.h (included in XGameRuntime.h)

**Library:** xgameruntime.lib

**Supported platforms:** Windows, XBOX One family consoles, and XBOX Series consoles

## Conceptual documentation

* [Granting players access to add-on content](/publishing/xstore-commerce/xstore-granting-access)
* [Enabling licensing testing](/publishing/xstore-commerce/xstore-licensing-setup)

## See also

[XStore](/reference/system/xstore/xstore_members)\
[XStoreAcquireLicenseForPackageAsync](/reference/system/xstore/functions/xstoreacquirelicenseforpackageasync)\
[XStoreAcquireLicenseForPackageResult](/reference/system/xstore/functions/xstoreacquirelicenseforpackageresult)\
[XStoreIsLicenseValid](/reference/system/xstore/functions/xstoreislicensevalid)\
[XStoreCloseLicenseHandle](/reference/system/xstore/functions/xstorecloselicensehandle)\
[XStorePackageLicenseLostCallback](/reference/system/xstore/functions/xstorepackagelicenselostcallback)\
[XStoreUnregisterPackageLicenseLost](/reference/system/xstore/functions/xstoreunregisterpackagelicenselost)\
[Granting players access to add-on content](/publishing/xstore-commerce/xstore-granting-access)


## Related topics

- [XStoreUnregisterPackageLicenseLost](/reference/system/xstore/functions/xstoreunregisterpackagelicenselost.md)
- [XStorePackageLicenseLostCallback](/reference/system/xstore/functions/xstorepackagelicenselostcallback.md)
- [XStoreAcquireLicenseForPackageResult](/reference/system/xstore/functions/xstoreacquirelicenseforpackageresult.md)
- [XStoreIsLicenseValid](/reference/system/xstore/functions/xstoreislicensevalid.md)
- [XStoreCloseLicenseHandle](/reference/system/xstore/functions/xstorecloselicensehandle.md)
