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

# XStoreQueryProductForPackageAsync

> XStoreQueryProductForPackageAsync

# XStoreQueryProductForPackageAsync

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

## 構文

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

### パラメーター

*storeContextHandle*   \_In\_\
Type: XStoreContextHandle

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

*productKinds*   \_In\_\
Type: [XStoreProductKind](https://docs.xbox.com/ja-jp/reference/system/xstore/enums/xstoreproductkind.md)

検索する製品の種類。

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

ストア パッケージを一意に識別する文字列。パッケージ識別子の詳細については、[ダウンロード可能なコンテンツ (DLC) の管理とライセンス](https://docs.xbox.com/ja-jp/publishing/xstore-commerce/xstore-dlc.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 の成功またはエラー コード。

## 解説

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

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

```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](https://docs.xbox.com/ja-jp/reference/system/xstore/xstore_members.md)\
[XStoreQueryProductForPackageResult](https://docs.xbox.com/ja-jp/reference/system/xstore/functions/xstorequeryproductforpackageresult.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

- [XStoreQueryProductForPackageResult](https://docs.xbox.com/ja-jp/reference/system/xstore/functions/xstorequeryproductforpackageresult.md)
- [XStoreQueryProductForCurrentGameAsync](https://docs.xbox.com/ja-jp/reference/system/xstore/functions/xstorequeryproductforcurrentgameasync.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)
- [XStoreProductKind](https://docs.xbox.com/ja-jp/reference/system/xstore/enums/xstoreproductkind.md)
