XUserResolveIssueWithUiUtf16Result

检索调用 XUserResolveIssueWithUiUtf16Async 的结果。

语法

HRESULT XUserResolveIssueWithUiUtf16Result(  
         XAsyncBlock* async  
)  

参数

async _Inout_
类型:XAsyncBlock*

我们传递给 XUserResolveIssueWithUiUtf16AsyncXAsyncBlock

返回值

类型:HRESULT

如果成功,则返回 S_OK;否则返回错误代码。 有关错误代码的列表,请参阅错误代码

返回代码 说明
S_OK 操作成功
E_ABORT 用户取消了操作

备注

如果 XUsers API 返回 E_GAMEUSER_RESOLVE_USER_ISSUE_REQUIRED 错误,则用户必须与系统用户界面 (UI) 交互来解决问题。 调用 XUserResolveIssueWithUiUtf16Async 以显示相应的系统 UI。

要显示用于使用非 Unicode URL 解决令牌问题的系统用户界面,请调用 XUserResolveIssueWithUiAsync

下面的示例演示如何显示系统 UI 以使用 URL 解决令牌问题。

HRESULT ResolveUserIssueComplete(XAsyncBlock* ab)
{
    if (SUCCEEDED_LOG(XUserResolveIssueWithUiResult(ab)))
    {
        appLog.AddLog("Successfully Resolved User Issue\n");
    }

    return S_OK;
}

HRESULT ResolveUserIssueUtf16Complete(XAsyncBlock* ab)
{
    if (SUCCEEDED_LOG(XUserResolveIssueWithUiUtf16Result(ab)))
    {
        appLog.AddLog("Successfully Resolved User Issue\n");
    }

    return S_OK;
}

HRESULT ResolveUserIssueWithUiAsync(
    XTaskQueueHandle queue,
    const char* narrowUrl = nullptr,
    const wchar_t* wideUrl = nullptr,
    bool useUtf16 = false)
{
    auto resolveAsyncBlock = std::make_unique<XAsyncBlock>();
    ZeroMemory(resolveAsyncBlock.get(), sizeof(*resolveAsyncBlock));
    resolveAsyncBlock->queue = queue;
    resolveAsyncBlock->context = this;

    if (useUtf16)
    {
        resolveAsyncBlock->callback = [](XAsyncBlock* ab)
        {
            auto asyncBlock = std::unique_ptr<XAsyncBlock>(ab);
            LOG_IF_FAILED(static_cast<User*>(ab->context)->ResolveUserIssueUtf16Complete(ab));
        };

        if (SUCCEEDED_LOG(XUserResolveIssueWithUiUtf16Async(
            _handle.get(),
            wideUrl,
            resolveAsyncBlock.get())))
        {
            // The call succeeded, so release the std::unique_ptr ownership of XAsyncBlock* since the callback will take over ownership.
            // If the call fails, the std::unique_ptr will keep ownership and delete the XAsyncBlock*
            resolveAsyncBlock.release();
        }
    }
    else
    {
        resolveAsyncBlock->callback = [](XAsyncBlock* ab)
        {
            auto asyncBlock = std::unique_ptr<XAsyncBlock>(ab);
            LOG_IF_FAILED(static_cast<User*>(ab->context)->ResolveUserIssueComplete(ab));
        };

        if (SUCCEEDED_LOG(XUserResolveIssueWithUiAsync(
            _handle.get(),
            narrowUrl,
            resolveAsyncBlock.get())))
        {
            // The call succeeded, so release the std::unique_ptr ownership of XAsyncBlock* since the callback will take over ownership.
            // If the call fails, the std::unique_ptr will keep ownership and delete the XAsyncBlock*
            resolveAsyncBlock.release();
        }
    }

    return S_OK;
}

要求

头文件:XUser.h

库:xgameruntime.lib

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

另请参阅

XUser

XUserResolveIssueWithUiUtf16Async

XUserResolveIssueWithUiAsync