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

# XStoreQueryConsumableBalanceRemainingAsync

> XStoreQueryConsumableBalanceRemainingAsync

# XStoreQueryConsumableBalanceRemainingAsync

指定された製品 ID の消費型製品の残高を取得します。

## 構文

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

### パラメーター

*storeContextHandle*   \_In\_\
Type: XStoreContextHandle

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

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

残高を取得する消費型製品の ID。

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

## 解説

残りの消費型製品の残高とこの関数の実行結果を取得するには、この関数を呼び出した後に [XStoreQueryConsumableBalanceRemainingResult](https://docs.xbox.com/ja-jp/reference/system/xstore/functions/xstorequeryconsumablebalanceremainingresult.md) を呼び出します。[XStoreQueryConsumableBalanceRemainingResult](https://docs.xbox.com/ja-jp/reference/system/xstore/functions/xstorequeryconsumablebalanceremainingresult.md) は、**XStoreQueryConsumableBalanceRemainingAsync** のコールバック関数内で実行する必要があります。次のコード スニペットは、指定された製品 ID の消費型製品の残高を取得する例を示しています。

```cpp theme={null}
void CALLBACK QueryConsumableBalanceRemainingCallback(XAsyncBlock* asyncBlock)
{
    XStoreConsumableResult result{};
    HRESULT hr = XStoreQueryConsumableBalanceRemainingResult(
        asyncBlock,
        &result);

    if (FAILED(hr))
    {
        printf("Failed retrieve the consumable balance remaining: 0x%x\r\n", hr);
        return;
    }

    printf("quantity: %d\r\n", result.quantity);
}

void QueryConsumableBalanceRemaining(XStoreContextHandle storeContextHandle, XTaskQueueHandle taskQueueHandle, const char* storeId)
{
    auto asyncBlock = std::make_unique<XAsyncBlock>();
    ZeroMemory(asyncBlock.get(), sizeof(*asyncBlock));
    asyncBlock->queue = taskQueueHandle;
    asyncBlock->callback = QueryConsumableBalanceRemainingCallback;

    HRESULT hr = XStoreQueryConsumableBalanceRemainingAsync(
        storeContextHandle,
        storeId,
        asyncBlock.get());

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

```

## 要件

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

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

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

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

* [ストアの基本操作](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)\
[XStoreQueryConsumableBalanceRemainingResult](https://docs.xbox.com/ja-jp/reference/system/xstore/functions/xstorequeryconsumablebalanceremainingresult.md)\
[XStoreCreateContext](https://docs.xbox.com/ja-jp/reference/system/xstore/functions/xstorecreatecontext.md)


## Related topics

- [XStoreQueryConsumableBalanceRemainingResult](https://docs.xbox.com/ja-jp/reference/system/xstore/functions/xstorequeryconsumablebalanceremainingresult.md)
- [XStoreConsumableResult](https://docs.xbox.com/ja-jp/reference/system/xstore/structs/xstoreconsumableresult.md)
- [基本的な Store 操作](https://docs.xbox.com/ja-jp/publishing/xstore-commerce/xstore-basic-operations.md)
- [XStore (API の内容)](https://docs.xbox.com/ja-jp/reference/system/xstore/xstore_members.md)
- [Unity プロジェクトでの GDK API 用 C# ラッパーの使用](https://docs.xbox.com/ja-jp/build/gdk-and-engines/unity/unity-api-wrappers.md)
