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

指定されたパッケージのストア製品情報を取得します。

## 構文

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

### パラメーター

*storeContextHandle*   \_In\_\
Type: XStoreContextHandle

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

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

検索する製品の種類。

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

ストア パッケージを一意に識別する文字列。パッケージ識別子の詳細については、[ダウンロード可能なコンテンツ (DLC) の管理とライセンス](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-manage-and-license-optional-packages)を参照してください。

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

## 解説

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

次のコード スニペットは、パッケージの製品情報を取得する例を示しています。

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


```

## 要件

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

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

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

## 関連項目

[XStore](/reference/system/xstore/xstore_members)\
[XStoreQueryProductForPackageResult](/reference/system/xstore/functions/xstorequeryproductforpackageresult)\
[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

- [XStoreQueryProductForPackageResult](/ja-jp/reference/system/xstore/functions/xstorequeryproductforpackageresult.md)
- [XStoreQueryProductForCurrentGameAsync](/ja-jp/reference/system/xstore/functions/xstorequeryproductforcurrentgameasync.md)
- [XStoreQueryProductsAsync](/ja-jp/reference/system/xstore/functions/xstorequeryproductsasync.md)
- [XStoreQueryAssociatedProductsForStoreIdResult](/ja-jp/reference/system/xstore/functions/xstorequeryassociatedproductsforstoreidresult.md)
- [XStoreProductKind](/ja-jp/reference/system/xstore/enums/xstoreproductkind.md)
