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

# XStoreQueryProductForCurrentGameAsync

> XStoreQueryProductForCurrentGameAsync

# XStoreQueryProductForCurrentGameAsync

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

## 構文

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

### パラメーター

*storeContextHandle*   \_In\_\
Type: XStoreContextHandle

[XStoreCreateContext](/reference/system/xstore/functions/xstorecreatecontext) から返される、ユーザーのストア コンテキスト ハンドル。

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

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

### 戻り値

Type: HRESULT

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

## 解説

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

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

```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://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-basic-store-operations)

## 関連項目

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


## Related topics

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