XStoreQueryConsumableBalanceRemainingAsync

获取指定产品 ID 的剩余易耗品余额。

语法

HRESULT XStoreQueryConsumableBalanceRemainingAsync(  
         const XStoreContextHandle storeContextHandle,  
         const char* storeProductId,  
         XAsyncBlock* async  
)  

参数

storeContextHandle _In_
类型:XStoreContextHandle

XStoreCreateContext 返回的用户的应用商店上下文句柄。

storeProductId _In_z_
类型:char*

要检索其余额的易耗品 ID。

async _Inout_
类型:XAsyncBlock*

用于定义正在进行的异步工作的 XAsyncBlockXAsyncBlock 可用于轮询调用的状态和检索调用结果。 有关详细信息,请参阅 XAsyncBlock

返回值

类型:HRESULT

HRESULT 成功或错误代码。

备注

要检索剩余易耗品余额以及此函数的执行结果,请在调用此函数后调用 XStoreQueryConsumableBalanceRemainingResultXStoreQueryConsumableBalanceRemainingResult 应该在 XStoreQueryConsumableBalanceRemainingAsync 的回调函数中执行。 以下代码段显示一个示例,用于检索指定产品 ID 的剩余易耗品余额。

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 主机

另请参阅

XStore
XStoreQueryConsumableBalanceRemainingResult
XStoreCreateContext