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

# XStoreQueryGameLicenseAsync

> XStoreQueryGameLicenseAsync

Retrieves information about the license that was acquired to allow the app to launch.

## Syntax

```cpp theme={null}
HRESULT XStoreQueryGameLicenseAsync(  
         const XStoreContextHandle storeContextHandle,  
         XAsyncBlock* async  
)  
```

### Parameters

*storeContextHandle*   \_In\_\
Type: XStoreContextHandle

The store context handle for the user returned by [XStoreCreateContext](https://docs.xbox.com/reference/system/xstore/functions/xstorecreatecontext.md).

*async*   \_Inout\_\
Type: [XAsyncBlock\*](https://docs.xbox.com/reference/system/xasync/structs/xasyncblock.md)

An [XAsyncBlock](https://docs.xbox.com/reference/system/xasync/structs/xasyncblock.md) defining the asynchronous work being done. The [XAsyncBlock](https://docs.xbox.com/reference/system/xasync/structs/xasyncblock.md) can be used to poll for the call's status and retrieve call results. See [XAsyncBlock](https://docs.xbox.com/reference/system/xasync/structs/xasyncblock.md) for more information.

### Return value

Type: HRESULT

HRESULT success or error code.

## Remarks

To retrieve the license information as well as the execution result of this function call [XStoreQueryGameLicenseResult](https://docs.xbox.com/reference/system/xstore/functions/xstorequerygamelicenseresult.md) after calling this function. [XStoreQueryGameLicenseResult](https://docs.xbox.com/reference/system/xstore/functions/xstorequerygamelicenseresult.md) should be called in the callback function for **XStoreQueryGameLicenseAsync**. The following code snippet shows an example of retrieving license information for the license that was acquired to allow the game to launch.

```cpp theme={null}
void CALLBACK GameLicenseCallback(XAsyncBlock* asyncBlock)
{
    XStoreGameLicense result{};

    HRESULT hr = XStoreQueryGameLicenseResult(
        asyncBlock,
        &result);

    if (FAILED(hr))
    {
        printf("Failed retrieve the game license result: 0x%x\r\n", hr);
        return;
    }

    printf("expirationDate        : %d\r\n", result.expirationDate);
    printf("isActive              : %s\r\n", result.isActive ? "true" : "false");
    printf("isDiscLicense         : %s\r\n", result.isDiscLicense ? "true" : "false");
    printf("isTrial               : %s\r\n", result.isTrial ? "true" : "false");
    printf("isTrialOwnedByThisUser: %s\r\n", result.isTrialOwnedByThisUser ? "true" : "false");
    printf("skuStoreId            : %s\r\n", result.skuStoreId);
    printf("trialTimeRemaining    : %d\r\n", result.trialTimeRemainingInSeconds);
    printf("trialUniqueId         : %s\r\n", result.trialUniqueId);
}

void QueryGameLicense(XStoreContextHandle storeContextHandle, XTaskQueueHandle taskQueueHandle)
{
    auto asyncBlock = std::make_unique<XAsyncBlock>();
    ZeroMemory(asyncBlock.get(), sizeof(*asyncBlock));
    asyncBlock->queue = taskQueueHandle;
    asyncBlock->callback = GameLicenseCallback;

    HRESULT hr = XStoreQueryGameLicenseAsync(
        storeContextHandle,
        asyncBlock.get());

    if (FAILED(hr))
    {
        printf("Failed to get the game license: 0x%x\r\n", hr);
        return;
    }
}
```

## Requirements

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

**Library:** xgameruntime.lib

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

## Conceptual documentation

* [Mods support for PC GDK titles](https://docs.xbox.com/build/core-features/common/packaging/packaging-mods.md)
* [Enabling licensing testing](https://docs.xbox.com/publishing/xstore-commerce/xstore-licensing-setup.md)
* [GDK Commerce Systems Overview](https://docs.xbox.com/publishing/xstore-commerce/xstore-overview.md)
* [Enabling XStore development and testing](https://docs.xbox.com/publishing/xstore-commerce/xstore-product-testing-setup.md)

## See also

[XStore](https://docs.xbox.com/reference/system/xstore/xstore_members.md)\
[XStoreQueryGameLicenseResult](https://docs.xbox.com/reference/system/xstore/functions/xstorequerygamelicenseresult.md)\
[XStoreCreateContext](https://docs.xbox.com/reference/system/xstore/functions/xstorecreatecontext.md)


## Related topics

- [XStoreQueryGameLicenseResult](https://docs.xbox.com/reference/system/xstore/functions/xstorequerygamelicenseresult.md)
- [XStoreGameLicense](https://docs.xbox.com/reference/system/xstore/structs/xstoregamelicense.md)
- [XStore on PC — DRM, license tokens, and sandboxes](https://docs.xbox.com/publishing/xstore-commerce/xstore-pc.md)
- [Enabling licensing testing](https://docs.xbox.com/publishing/xstore-commerce/xstore-licensing-setup.md)
- [Enabling XStore development and testing](https://docs.xbox.com/publishing/xstore-commerce/xstore-product-testing-setup.md)
