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

現在実行中のゲームのストア製品情報、その SKU と提供状況、およびその他のメタデータを提供します。

## 構文

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

### パラメーター

*storeContextHandle*   \_In\_\
Type: XStoreContextHandle

[XStoreCreateContext](https://docs.xbox.com/ja-jp/reference/system/xstore/functions/xstorecreatecontext.md) から返される、ユーザーのストア コンテキスト ハンドル。

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

実行中の非同期処理を定義する [XAsyncBlock](https://docs.xbox.com/ja-jp/reference/system/xasync/structs/xasyncblock.md)。[XAsyncBlock](https://docs.xbox.com/ja-jp/reference/system/xasync/structs/xasyncblock.md) は、呼び出しの状態のポーリングと呼び出し結果の取得に使用できます。詳細については、[XAsyncBlock](https://docs.xbox.com/ja-jp/reference/system/xasync/structs/xasyncblock.md) を参照してください。

### 戻り値

Type: HRESULT

HRESULT の成功またはエラー コード。

## 解説

ストア製品情報とこの関数の実行結果を取得するには、この関数を呼び出した後に [XStoreQueryProductForCurrentGameResult](https://docs.xbox.com/ja-jp/reference/system/xstore/functions/xstorequeryproductforcurrentgameresult.md) を呼び出します。

次のコード スニペットは、現在実行中のゲームのストア製品情報を取得する例を示しています。

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

## 要件

**ヘッダー:** XStore.h (XGameRuntime.h に含まれる)

**ライブラリ:** xgameruntime.lib

**サポートされているプラットフォーム:** Windows、XBOX One ファミリ本体および XBOX Series 本体

## 関連概念ドキュメント

* [ゲームにゲーム内購入を実装する](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/pc-dev/tutorials/pc-e2e-guide/e2e-services/e2e-in-game-purchases)
* [ストアの基本操作](https://docs.xbox.com/ja-jp/publishing/xstore-commerce/xstore-basic-operations.md)

## 関連項目

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


## Related topics

- [XStoreQueryProductForCurrentGameResult](https://docs.xbox.com/ja-jp/reference/system/xstore/functions/xstorequeryproductforcurrentgameresult.md)
- [XStoreQueryProductForPackageAsync](https://docs.xbox.com/ja-jp/reference/system/xstore/functions/xstorequeryproductforpackageasync.md)
- [XStoreQueryProductForPackageResult](https://docs.xbox.com/ja-jp/reference/system/xstore/functions/xstorequeryproductforpackageresult.md)
- [XStoreQueryAssociatedProductsForStoreIdResult](https://docs.xbox.com/ja-jp/reference/system/xstore/functions/xstorequeryassociatedproductsforstoreidresult.md)
- [XStoreQueryProductsAsync](https://docs.xbox.com/ja-jp/reference/system/xstore/functions/xstorequeryproductsasync.md)
