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

# XStoreQueryProductsAsync

> XStoreQueryProductsAsync

# XStoreQueryProductsAsync

現在のゲームに関連付けられている指定された製品の掲載情報を、それらがゲーム内で購入可能かどうかに関係なく返します。

## 構文

```cpp theme={null}
HRESULT XStoreQueryProductsAsync(  
         const XStoreContextHandle storeContextHandle,  
         XStoreProductKind productKinds,  
         const char** storeIds,  
         size_t storeIdsCount,  
         const char** actionFilters,  
         size_t actionFiltersCount,  
         XAsyncBlock* async  
)  
```

### パラメーター

*storeContextHandle*   \_In\_\
Type: XStoreContextHandle

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

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

返す製品の種類。

*storeIds*   \_In\_z\_count\_(storeIdsCount)\
Type: char\*\*

取得する製品のストア識別子。

*storeIdsCount*   \_In\_\
Type: size\_t

**storeIds** のリスト内の製品数。
この数は 100 を超えないようにする必要があります。

*actionFilters*   \_In\_opt\_z\_count\_(actionFiltersCount)\
Type: char\*\*

製品ドキュメントに保存されている何らかのアクションで結果を制限します。
既定では、この API は購入不可能な製品を含むすべての製品を返しますが、アクション フィルターを使用して結果を制限できます。
たとえば、購入可能な製品のみを取得する場合は "Purchase" を使用し、ライセンス可能な製品のみを取得する場合は "License" を使用します。
その他のアクション フィルターには "Fulfill"、"Browse"、"Curate"、"Details"、"Redeem" があります。

*actionFiltersCount*   \_In\_\
Type: size\_t

**actionFilters** 内のフィルターの数。

*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 の成功またはエラー コード。

## 解説

掲載情報とこの関数の実行結果を取得するには、[XStoreQueryProductsResult](/reference/system/xstore/functions/xstorequeryproductsresult) を呼び出します。

要求内に 100 を超える storeID を指定した場合、この API は失敗します。
大きなカタログを扱う場合は、各クエリを 100 個未満の製品に制限してください。

現在のゲーム内でプレイヤーが購入可能なすべての製品の詳細を取得するには、代わりに [XStoreQueryAssociatedProductsAsync](/reference/system/xstore/functions/xstorequeryassociatedproductsasync) を使用します。

次のコード スニペットは、現在のゲームに関連付けられた指定された製品の掲載情報を取得する例を示しています。

```cpp theme={null}

void ProcessResults(XStoreProductQueryHandle queryHandle)
{
    HRESULT hr = XStoreEnumerateProductsQuery(
        queryHandle,
        nullptr,
        EnumerateProductsQueryCallback);

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

    XStoreCloseProductsQueryHandle(queryHandle);
}

void CALLBACK QueryProductsCallback(XAsyncBlock* asyncBlock)
{
    XStoreProductQueryHandle queryHandle = nullptr;

    HRESULT hr = XStoreQueryProductsResult(
        asyncBlock,
        &queryHandle);

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

     ProcessResults(queryHandle);
}

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

    asyncBlock->callback = QueryProductsCallback;

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

    const char* storeIds[] =
    {
        "9YYYYYYYYYYY",
        "9ZZZZZZZZZZZ",
    };

    // This is only needed if you want to restrict to items that are currently purchasable.
    // If you want items that have been sold in the past,
    // but are no longer available for purchase, then
    // pass in nullptr or an empty array for the actionFilters.
    const char* actionFilters[] =
    {
        "Purchase"
    };

    HRESULT hr = XStoreQueryProductsAsync(
        storeContextHandle,
        allProductKinds,
        storeIds,
        ARRAYSIZE(storeIds),
        actionFilters,
        ARRAYSIZE(actionFilters),
        asyncBlock.get());

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

```

## 要件

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

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

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

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

* [ストアの基本操作](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-basic-store-operations)
* [プレイヤーにアドオン コンテンツへのアクセス権を付与する](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-granting-access-to-content)
* [Microsoft Store API のきめ細かなレート制限](/publishing/xstore-commerce/xstore-fgrl)

## 関連項目

[XStore](/reference/system/xstore/xstore_members)
[XStoreQueryProductsResult](/reference/system/xstore/functions/xstorequeryproductsresult)\
[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)\
[ストアの基本操作](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-basic-store-operations)\
[プレイヤーにアドオン コンテンツへのアクセス権を付与する](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-granting-access-to-content)


## Related topics

- [XStoreQueryProductsResult](/ja-jp/reference/system/xstore/functions/xstorequeryproductsresult.md)
- [XStoreQueryProductForPackageAsync](/ja-jp/reference/system/xstore/functions/xstorequeryproductforpackageasync.md)
- [XStoreQueryProductForPackageResult](/ja-jp/reference/system/xstore/functions/xstorequeryproductforpackageresult.md)
- [XStoreQueryProductForCurrentGameAsync](/ja-jp/reference/system/xstore/functions/xstorequeryproductforcurrentgameasync.md)
- [XStoreQueryAssociatedProductsForStoreIdResult](/ja-jp/reference/system/xstore/functions/xstorequeryassociatedproductsforstoreidresult.md)
