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

Recupera informações sobre a licença que foi adquirida para permitir a inicialização do aplicativo.

## Sintaxe

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

### Parâmetros

*storeContextHandle*   \_In\_\
Tipo: XStoreContextHandle

O identificador de contexto da loja para o usuário retornado por [XStoreCreateContext](/pt-BR/reference/system/xstore/functions/xstorecreatecontext).

*async*   \_Inout\_\
Tipo: [XAsyncBlock\*](/pt-BR/reference/system/xasync/structs/xasyncblock)

Um [XAsyncBlock](/pt-BR/reference/system/xasync/structs/xasyncblock) que define o trabalho assíncrono que está sendo realizado. O [XAsyncBlock](/pt-BR/reference/system/xasync/structs/xasyncblock) pode ser usado para sondar o status da chamada e recuperar os resultados da chamada. Consulte [XAsyncBlock](/pt-BR/reference/system/xasync/structs/xasyncblock) para obter mais informações.

### Valor retornado

Tipo: HRESULT

Código de sucesso ou erro HRESULT.

## Comentários

Para recuperar as informações da licença, bem como o resultado da execução desta função, chame [XStoreQueryGameLicenseResult](/pt-BR/reference/system/xstore/functions/xstorequerygamelicenseresult) depois de chamar esta função. [XStoreQueryGameLicenseResult](/pt-BR/reference/system/xstore/functions/xstorequerygamelicenseresult) deve ser chamada na função de retorno de chamada de **XStoreQueryGameLicenseAsync**. O snippet de código a seguir mostra um exemplo de recuperação das informações da licença que foi adquirida para permitir a inicialização do jogo.

```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;
    }
}
```

## Requisitos

**Cabeçalho:** XStore.h (incluído em XGameRuntime.h)

**Biblioteca:** xgameruntime.lib

**Plataformas com suporte:** Windows, consoles da família XBOX One e consoles XBOX Series

## Documentação conceitual

* [Suporte a mods para títulos do GDK para PC](/pt-BR/build/core-features/common/packaging/packaging-mods)
* [Habilitar testes de licenciamento](/pt-BR/publishing/xstore-commerce/xstore-licensing-setup)
* [Visão geral dos sistemas de comércio do GDK](/pt-BR/publishing/xstore-commerce/xstore-overview)
* [Habilitar o desenvolvimento e os testes do XStore](/pt-BR/publishing/xstore-commerce/xstore-product-testing-setup)

## Confira também

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


## Related topics

- [XStoreQueryGameLicenseAsync](/reference/system/xstore/functions/xstorequerygamelicenseasync.md)
- [XStoreQueryGameLicenseResult](/reference/system/xstore/functions/xstorequerygamelicenseresult.md)
