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

# XStoreQueryConsumableBalanceRemainingAsync

> XStoreQueryConsumableBalanceRemainingAsync

# XStoreQueryConsumableBalanceRemainingAsync

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

## 構文

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

### パラメーター

*storeContextHandle*   \_In\_\
Type: XStoreContextHandle

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

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

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

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

## 解説

残りの消費型製品の残高とこの関数の実行結果を取得するには、この関数を呼び出した後に [XStoreQueryConsumableBalanceRemainingResult](/reference/system/xstore/functions/xstorequeryconsumablebalanceremainingresult) を呼び出します。[XStoreQueryConsumableBalanceRemainingResult](/reference/system/xstore/functions/xstorequeryconsumablebalanceremainingresult) は、**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://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-basic-store-operations)

## 関連項目

[XStore](/reference/system/xstore/xstore_members)\
[XStoreQueryConsumableBalanceRemainingResult](/reference/system/xstore/functions/xstorequeryconsumablebalanceremainingresult)\
[XStoreCreateContext](/reference/system/xstore/functions/xstorecreatecontext)


## Related topics

- [XStoreQueryConsumableBalanceRemainingResult](/ja-jp/reference/system/xstore/functions/xstorequeryconsumablebalanceremainingresult.md)
- [XStoreConsumableResult](/ja-jp/reference/system/xstore/structs/xstoreconsumableresult.md)
- [基本的な Store 操作](/ja-jp/publishing/xstore-commerce/xstore-basic-operations.md)
- [XStore](/ja-jp/reference/system/xstore/xstore_members.md)
- [GDK 向け Unity C# API ラッパー](/ja-jp/build/gdk-and-engines/unity/unity-api-wrappers.md)
