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

# XStoreQueryProductForCurrentGameAsync

> XStoreQueryProductForCurrentGameAsync

# XStoreQueryProductForCurrentGameAsync

Fournit les informations de produit du Store pour le jeu en cours d'exécution, ses SKU et disponibilités, ainsi que d'autres métadonnées.

## Syntaxe

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

### Paramètres

*storeContextHandle*   \_In\_\
Type : XStoreContextHandle

Handle de contexte du Store pour l'utilisateur, retourné par [XStoreCreateContext](https://docs.xbox.com/fr-CA/reference/system/xstore/functions/xstorecreatecontext.md).

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

Un [XAsyncBlock](https://docs.xbox.com/fr-CA/reference/system/xasync/structs/xasyncblock.md) définissant le travail asynchrone en cours. Le [XAsyncBlock](https://docs.xbox.com/fr-CA/reference/system/xasync/structs/xasyncblock.md) peut être utilisé pour interroger l'état de l'appel et récupérer les résultats de l'appel. Pour plus d'informations, consultez [XAsyncBlock](https://docs.xbox.com/fr-CA/reference/system/xasync/structs/xasyncblock.md).

### 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 [XStoreQueryProductForCurrentGameResult](https://docs.xbox.com/fr-CA/reference/system/xstore/functions/xstorequeryproductforcurrentgameresult.md) après avoir appelé cette fonction.

L'extrait de code suivant montre un exemple de récupération des informations de produit du Store pour le jeu en cours d'exécution.

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

    HRESULT hr = XStoreQueryProductForCurrentGameResult(
        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 QueryProductForCurrentGame(XStoreContextHandle storeContextHandle, XTaskQueueHandle taskQueueHandle)
{
    auto asyncBlock = std::make_unique<XAsyncBlock>();
    ZeroMemory(asyncBlock.get(), sizeof(*asyncBlock));
    asyncBlock->queue = taskQueueHandle;

    asyncBlock->callback = QueryProductForCurrentGameCallback;

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

    if (FAILED(hr))
    {
        printf("Failed to get product for current game: 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

## Documentation conceptuelle

* [Implémenter les achats en jeu dans votre jeu](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/pc-dev/tutorials/pc-e2e-guide/e2e-services/e2e-in-game-purchases)
* [Opérations de base du Store](https://docs.xbox.com/fr-CA/publishing/xstore-commerce/xstore-basic-operations.md)

## Voir aussi

[XStore](https://docs.xbox.com/fr-CA/reference/system/xstore/xstore_members.md)\
[XStoreQueryProductForCurrentGameResult](https://docs.xbox.com/fr-CA/reference/system/xstore/functions/xstorequeryproductforcurrentgameresult.md)\
[XStoreQueryAssociatedProductsAsync](https://docs.xbox.com/fr-CA/reference/system/xstore/functions/xstorequeryassociatedproductsasync.md)\
[XStoreQueryEntitledProductsAsync](https://docs.xbox.com/fr-CA/reference/system/xstore/functions/xstorequeryentitledproductsasync.md)\
[XStoreQueryProductsAsync](https://docs.xbox.com/fr-CA/reference/system/xstore/functions/xstorequeryproductsasync.md)\
[XStoreQueryProductForCurrentGameAsync](https://docs.xbox.com/fr-CA/reference/system/xstore/functions/xstorequeryproductforcurrentgameasync.md)\
[XStoreQueryProductForPackageAsync](https://docs.xbox.com/fr-CA/reference/system/xstore/functions/xstorequeryproductforpackageasync.md)


## Related topics

- [XStoreQueryProductForCurrentGameResult](https://docs.xbox.com/fr-CA/reference/system/xstore/functions/xstorequeryproductforcurrentgameresult.md)
- [XStoreQueryProductsAsync](https://docs.xbox.com/fr-CA/reference/system/xstore/functions/xstorequeryproductsasync.md)
- [XStoreQueryProductForPackageAsync](https://docs.xbox.com/fr-CA/reference/system/xstore/functions/xstorequeryproductforpackageasync.md)
- [XStoreQueryProductForPackageResult](https://docs.xbox.com/fr-CA/reference/system/xstore/functions/xstorequeryproductforpackageresult.md)
- [XStoreQueryProductsResult](https://docs.xbox.com/fr-CA/reference/system/xstore/functions/xstorequeryproductsresult.md)
