XStoreReportConsumableFulfillmentAsync

消耗指定数量的易耗品。 有关详细信息,请参阅 基于易耗品的生态系统,了解有关实现和使用易耗品的更多信息。

语法

HRESULT XStoreReportConsumableFulfillmentAsync(  
         const XStoreContextHandle storeContextHandle,  
         const char* storeProductId,  
         uint32_t quantity,  
         GUID trackingId,  
         XAsyncBlock* async  
)  

参数

storeContextHandle _In_
类型:XStoreContextHandle

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

storeProductId _In_z_
类型:char*

您想要将其报告为已完成的易耗的附加内容的 Store ID。

quantity _In_
类型:uint32_t

您想要将其报告为已完成的易耗的附加内容的单位数。 对于应用商店托管的易耗品(即 Microsoft 跟踪余额的易耗品),指定已消耗的单位数。 对于游戏托管的易耗品(即开发者跟踪余额的易耗品),指定 1。

trackingId _In_
类型:GUID

一个开发者提供的 GUID,可标识实施情况与之相关联的具体交易记录以用于跟踪。

async _Inout_
类型:XAsyncBlock*

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

返回值

类型:HRESULT

HRESULT 成功或错误代码。

备注

要检索此函数的结果,请在调用此函数后调用 XStoreReportConsumableFulfillmentResult

以下代码段显示一个使用一些易耗品的示例。

void CALLBACK ReportConsumableFulfillmentCallback(XAsyncBlock* asyncBlock)
{
    XStoreConsumableResult result{};
    HRESULT hr = XStoreReportConsumableFulfillmentResult(
        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 ReportConsumableFulfillment(XStoreContextHandle storeContextHandle, XTaskQueueHandle taskQueueHandle, const char* storeId, uint32_t quantity, GUID trackingId)
{
    auto asyncBlock = std::make_unique<XAsyncBlock>();
    ZeroMemory(asyncBlock.get(), sizeof(*asyncBlock));
    asyncBlock->queue = taskQueueHandle;
    asyncBlock->context = taskQueueHandle;
    asyncBlock->callback = ReportConsumableFulfillmentCallback;

    HRESULT hr = XStoreReportConsumableFulfillmentAsync(
        storeContextHandle,
        storeId,
        quantity,
        trackingId,
        asyncBlock.get());

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

    // Wait a while for the callbacks to run
    Sleep(5000);
}

要求

头文件:XStore.h(包含在 XGameRuntime.h 中)

库:xgameruntime.lib

支持平台:Windows、Xbox One 系列主机和 Xbox Series 主机

另请参阅

XStore
基于易耗品的生态系统XStoreReportConsumableFulfillmentResult