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

# XStoreQueryProductForPackageAsync

> XStoreQueryProductForPackageAsync

# XStoreQueryProductForPackageAsync

Récupère les informations de produit du Store pour le package spécifié.

## Syntaxe

```cpp theme={null}
HRESULT XStoreQueryProductForPackageAsync(  
         const XStoreContextHandle storeContextHandle,  
         XStoreProductKind productKinds,  
         const char* packageIdentifier,  
         XAsyncBlock* async  
)  
```

### Paramètres

*storeContextHandle*   \_In\_\
Type : XStoreContextHandle

Handle de contexte du Store de l'utilisateur, retourné par [XStoreCreateContext](/fr/reference/system/xstore/functions/xstorecreatecontext).

*productKinds*   \_In\_\
Type : [XStoreProductKind](/fr/reference/system/xstore/enums/xstoreproductkind)

Type des produits à rechercher.

*packageIdentifier*   \_In\_z\_\
Type : char\*

Chaîne qui identifie de manière unique un package du Store. Pour plus d'informations sur les identificateurs de package, consultez [Gérer et concéder sous licence du contenu téléchargeable (DLC)](/fr/publishing/xstore-commerce/xstore-dlc).

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

[XAsyncBlock](/fr/reference/system/xasync/structs/xasyncblock) définissant le travail asynchrone en cours. Le [XAsyncBlock](/fr/reference/system/xasync/structs/xasyncblock) peut être utilisé pour interroger l'état de l'appel et récupérer ses résultats. Pour plus d'informations, consultez [XAsyncBlock](/fr/reference/system/xasync/structs/xasyncblock).

### Valeur de retour

Type : HRESULT

Code de réussite ou d'erreur HRESULT.

## Remarques

Pour récupérer les informations de produit du Store ainsi que le résultat de l'exécution de cette fonction, appelez [XStoreQueryProductForPackageResult](/fr/reference/system/xstore/functions/xstorequeryproductforpackageresult) après avoir appelé cette fonction.

L'extrait de code suivant montre un exemple de récupération des informations de produit pour un package.

```cpp theme={null}
void CALLBACK QueryProductForPackageCallback(XAsyncBlock* asyncBlock)
{
    XStoreProductQueryHandle queryHandle = nullptr;

    HRESULT hr = XStoreQueryProductForPackageResult(
        asyncBlock,
        &queryHandle);

    if (FAILED(hr))
    {
        printf("Failed retrieve the product query handle: 0x%x\r\n", hr);
        XStoreCloseProductsQueryHandle(queryHandle);
        return;
    }

    // Use result of query

     XStoreCloseProductsQueryHandle(queryHandle);
}

void QueryProductForPackage(XStoreContextHandle storeContextHandle, const char* packageIdentifier)
{
    auto asyncBlock = std::make_unique<XAsyncBlock>();
    ZeroMemory(asyncBlock.get(), sizeof(*asyncBlock));
    asyncBlock->queue = taskQueueHandle;
    asyncBlock->callback = QueryProductForPackageCallback;

    XStoreProductKind allProductKinds =
        XStoreProductKind::Consumable |
        XStoreProductKind::Durable |
        XStoreProductKind::Game |
        XStoreProductKind::Pass |
        XStoreProductKind::UnmanagedConsumable;

    HRESULT hr = XStoreQueryProductForPackageAsync(
        storeContextHandle,
        allProductKinds,
        packageIdentifier,
        asyncBlock.get());

    if (FAILED(hr))
    {
        printf("Failed to get product for package: 0x%x\r\n", hr);
        return;
    }
}


```

## Configuration requise

**En-tête :** XStore.h (inclus dans XGameRuntime.h)

**Bibliothèque :** xgameruntime.lib

**Plateformes prises en charge :** Windows, consoles de la famille XBOX One et consoles XBOX Series

## Voir aussi

[XStore](/fr/reference/system/xstore/xstore_members)\
[XStoreQueryProductForPackageResult](/fr/reference/system/xstore/functions/xstorequeryproductforpackageresult)\
[XStoreQueryAssociatedProductsAsync](/fr/reference/system/xstore/functions/xstorequeryassociatedproductsasync)\
[XStoreQueryEntitledProductsAsync](/fr/reference/system/xstore/functions/xstorequeryentitledproductsasync)\
[XStoreQueryProductsAsync](/fr/reference/system/xstore/functions/xstorequeryproductsasync)\
[XStoreQueryProductForCurrentGameAsync](/fr/reference/system/xstore/functions/xstorequeryproductforcurrentgameasync)\
[XStoreQueryProductForPackageAsync](/fr/reference/system/xstore/functions/xstorequeryproductforpackageasync)


## Related topics

- [XStoreQueryProductForPackageAsync](/reference/system/xstore/functions/xstorequeryproductforpackageasync.md)
- [XStoreQueryProductForPackageResult](/reference/system/xstore/functions/xstorequeryproductforpackageresult.md)
