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

# XStoreShowRedeemTokenUIAsync

> XStoreShowRedeemTokenUIAsync

# XStoreShowRedeemTokenUIAsync

为当前用户触发指定令牌的令牌兑换。

## 语法

```cpp theme={null}
HRESULT XStoreShowRedeemTokenUIAsync(  
         const XStoreContextHandle storeContextHandle,  
         const char* token,  
         const char** allowedStoreIds,  
         size_t allowedStoreIdsCount,  
         bool disallowCsvRedemption,  
         XAsyncBlock* async  
)  
```

### 参数

*storeContextHandle*   \_In\_\
类型：XStoreContextHandle

[XStoreCreateContext](/reference/system/xstore/functions/xstorecreatecontext) 为用户返回的商店上下文句柄。

*token*   \_In\_z\_\
类型：char\*

要兑换的令牌。此值不能为空或 null，如果要在不提供代码以在 UI 中预填充的情况下调出 UI，请传入单个空格 " "。

*allowedStoreIds*   \_In\_z\_count\_(allowedStoreIdsCount)\
类型：char\*\*

允许你限制 5x5 代码仅适用于特定产品。

*allowedStoreIdsCount*   \_In\_\
类型：size\_t

**allowedStoreIds** 中的元素数量。

*disallowCsvRedemption*   \_In\_\
类型：bool

阻止兑换 CSV（礼品卡/货币样式的 5x5）。

*async*   \_Inout\_\
类型：[XAsyncBlock\*](/reference/system/xasync/structs/xasyncblock)

定义正在完成的异步工作的 [XAsyncBlock](/reference/system/xasync/structs/xasyncblock)。[XAsyncBlock](/reference/system/xasync/structs/xasyncblock) 可用于轮询调用的状态并检索调用结果。有关详细信息，请参阅 [XAsyncBlock](/reference/system/xasync/structs/xasyncblock)。

### 返回值

类型：HRESULT

HRESULT 成功或错误代码。

## 备注

要检索此函数调用的执行结果，请在调用此函数之后调用 [XStoreShowRedeemTokenUIResult](/reference/system/xstore/functions/xstoreshowredeemtokenuiresult)。

以下代码片段展示了启动令牌兑换 UI 的示例。

```cpp theme={null}
void CALLBACK ShowRedeemTokenUICallback(XAsyncBlock* asyncBlock)
{
    HRESULT hr = XStoreShowRedeemTokenUIResult(asyncBlock);

    if (FAILED(hr))
    {
        printf("Failed redeem token: 0x%x\r\n", hr);
        return;
    }
}

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

    HRESULT hr = XStoreShowRedeemTokenUIAsync(
        storeContextHandle,
        token,
        nullptr,    // Can restrict to specific store IDs
        0,
        false,      // Can prevent CSV (cash gift cards)
        asyncBlock.get());

    if (FAILED(hr))
    {
        printf("Failed to request redeem token: 0x%x\r\n", hr);
        return;
    }
}


```

## 要求

**头文件：** XStore.h（包含在 XGameRuntime.h 中）

**库：** xgameruntime.lib

**支持的平台：** Windows、XBOX One 系列主机和 XBOX Series 主机

## 另请参阅

[XStore](/reference/system/xstore/xstore_members)\
[XStoreShowRedeemTokenUIResult](/reference/system/xstore/functions/xstoreshowredeemtokenuiresult)


## Related topics

- [XStoreShowRedeemTokenUIResult](/zh-CN/reference/system/xstore/functions/xstoreshowredeemtokenuiresult.md)
- [XStore](/zh-CN/reference/system/xstore/xstore_members.md)
- [面向 GDK 的 Unity C# API 包装器](/zh-CN/build/gdk-and-engines/unity/unity-api-wrappers.md)
- [PFInventoryRedeemMicrosoftStoreInventoryItemsRequest](/zh-CN/services/playfab/api-references/c/pfinventorytypes/structs/pfinventoryredeemmicrosoftstoreinventoryitemsrequest.md)
- [XStoreShowPurchaseUIAsync](/zh-CN/reference/system/xstore/functions/xstoreshowpurchaseuiasync.md)
