> ## 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.

# XStoreQueryGameLicenseAsync

> 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](/reference/system/xstore/functions/xstorecreatecontext).

*async*   \_Inout\_\
Type: [XAsyncBlock\*](/reference/system/xasync/structs/xasyncblock)

An [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) defining the asynchronous work being done. The [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) can be used to poll for the call's status and retrieve call results. See [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) 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](/reference/system/xstore/functions/xstorequerygamelicenseresult) after calling this function. [XStoreQueryGameLicenseResult](/reference/system/xstore/functions/xstorequerygamelicenseresult) 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](/build/core-features/common/packaging/packaging-mods)
* [Enabling licensing testing](/publishing/xstore-commerce/xstore-licensing-setup)
* [GDK Commerce Systems Overview](/publishing/xstore-commerce/xstore-overview)
* [Enabling XStore development and testing](/publishing/xstore-commerce/xstore-product-testing-setup)

## See also

[XStore](/reference/system/xstore/xstore_members)\
[XStoreQueryGameLicenseResult](/reference/system/xstore/functions/xstorequerygamelicenseresult)\
[XStoreCreateContext](/reference/system/xstore/functions/xstorecreatecontext)


## Related topics

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