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

# XStoreQueryAddOnLicensesAsync

> XStoreQueryAddOnLicensesAsync

# XStoreQueryAddOnLicensesAsync

Enumera as licenças de todos os complementos duráveis que estão anexados a uma licença de jogo digital.
Isso se aplica somente a duráveis sem tipos de pacote e só pode ser usado com uma licença digital, não com licenças de disco.
Executar isso com uma licença de disco resultará em resultados vazios, mesmo que existam duráveis individuais que o usuário possua ou possa licenciar.
Para cenários de disco, use [XStoreAcquireLicenseForDurablesAsync](/pt-BR/reference/system/xstore/functions/xstoreacquirelicensefordurablesasync) em vez disso.

## Sintaxe

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

### Parâmetros

*storeContextHandle*   \_In\_\
Tipo: XStoreContextHandle

O identificador de contexto da loja do 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 feito.
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 êxito ou de erro HRESULT.

## Comentários

Para recuperar a licença do complemento, bem como o resultado da execução desta função, chame [XStoreQueryAddonLicensesResult](/pt-BR/reference/system/xstore/functions/xstorequeryaddonlicensesresult) após chamar esta função.
Para recuperar o número de licenças obtidas por esta função, chame [XStoreQueryAddonLicensesResultCount](/pt-BR/reference/system/xstore/functions/xstorequeryaddonlicensesresultcount) após chamar esta função.
A função de contagem de resultados é importante, pois permitirá que você determine o tamanho apropriado da matriz a ser passada para a função de resultado.

O snippet de código a seguir mostra um exemplo de recuperação de licenças de complementos duráveis (sem pacote) que o usuário possui ou pode licenciar:

```cpp theme={null}
void CALLBACK QueryAddOnLicensesCallback(XAsyncBlock* asyncBlock)
{
    uint32_t count;
    HRESULT hr = XStoreQueryAddOnLicensesResultCount(
        asyncBlock,
        &count);

    if (FAILED(hr))
    {
        printf("Failed retrieve the add-on license count: 0x%x\r\n", hr);
        return;
    }

    printf("Number of add-on licenses: %d", count);

    XStoreAddonLicense* addOnLicenses = new XStoreAddonLicense[count];
    hr = XStoreQueryAddOnLicensesResult(asyncBlock, count, &addOnLicenses);

    if (FAILED(hr))
    {
        printf("Failed retrieve the add-on licenses: 0x%x\r\n", hr);
        delete[] addOnLicenses;
        return;
    }

    for (uint32_t index = 0; index < count; index++)
    {
        printf("expirationDate : %d\r\n", addOnLicenses[index].expirationDate);
        printf("inAppOfferToken: %s\r\n", addOnLicenses[index].inAppOfferToken);
        printf("isActive       : %s\r\n", addOnLicenses[index].isActive ? "true" : "false");
        printf("skuStoreId     : %s\r\n", addOnLicenses[index].skuStoreId);
    }

    delete[] addOnLicenses;
}

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

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

    if (FAILED(hr))
    {
        printf("Failed to get add-on licenses: 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

* [Operações básicas da loja](/pt-BR/publishing/xstore-commerce/xstore-basic-operations)
* [Habilitando testes de licenciamento](/pt-BR/publishing/xstore-commerce/xstore-licensing-setup)

## Confira também

[XStore](/pt-BR/reference/system/xstore/xstore_members)\
[XStoreQueryAddonLicensesResult](/pt-BR/reference/system/xstore/functions/xstorequeryaddonlicensesresult)\
[XStoreQueryAddonLicensesResultCount](/pt-BR/reference/system/xstore/functions/xstorequeryaddonlicensesresultcount)


## Related topics

- [XStoreQueryAddOnLicensesAsync](/reference/system/xstore/functions/xstorequeryaddonlicensesasync.md)
- [XStoreQueryAddOnLicensesResult](/reference/system/xstore/functions/xstorequeryaddonlicensesresult.md)
- [Basic store operations](/publishing/xstore-commerce/xstore-basic-operations.md)
- [Enabling licensing testing](/publishing/xstore-commerce/xstore-licensing-setup.md)
- [라이선싱 테스트 활성화](/ko/publishing/xstore-commerce/xstore-licensing-setup.md)
