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

# XGameRuntimeUninitialize

> XGameRuntimeUninitialize

# XGameRuntimeUninitialize

取消初始化 Gaming Runtime。

## Syntax

```cpp theme={null}
void XGameRuntimeUninitialize(  
)  
```

### Parameters

无。

### Return value

类型：void

## Remarks

若要在游戏中使用 Gaming Runtime 功能，请先通过调用 [XGameRuntimeInitialize](/reference/system/xgameruntimeinit/functions/xgameruntimeinitialize) 函数来初始化 Gaming Runtime。当你的游戏完成对 Gaming Runtime 的使用并准备退出时，请通过调用 **XGameRuntimeUninitialize** 函数来取消初始化 Gaming Runtime。请尽可能晚地（但需在游戏退出之前）调用 **XGameRuntimeUninitialize** 函数，通常在游戏的入口点函数中调用。

以下示例演示了如何在基于 Visual Studio 中 **Direct3D 12 Desktop Game** 模板的游戏的入口点函数中使用 [XGameRuntimeInitialize](/reference/system/xgameruntimeinit/functions/xgameruntimeinitialize) 和 **XGameRuntimeUninitialize** 函数。在实例化并注册 **Game** 对象之前调用 **XGameRuntimeInitialize** 函数，并在重置 **Game** 对象之后但在入口点函数返回之前调用 **XGameRuntimeUninitialize** 函数。

```cpp theme={null}
// Entry point
int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    // Initialize the Gaming Runtime before
    // performing any other activity.
    if (FAILED(XGameRuntimeInitialize()))
        return 1;

    if (!XMVerifyCPUSupport())
        return 1;

    g_game = std::make_unique<Game>();

    // Register class and create window
    {
        // Code omitted for brevity.
        ...
    }

    // Main message loop
    MSG msg = {};
    while (WM_QUIT != msg.message)
    {
        // Code omitted for brevity.
        ...
    }

    g_game.reset();

    // Uninitialize the Gaming Runtime after
    // all other activity has been completed.
    XGameRuntimeUninitialize();

    return (int) msg.wParam;
}
```

## Requirements

**头文件：** XGameRuntimeInit.h

**库：** xgameruntime.lib

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

## Conceptual documentation

* [什么是 Microsoft 游戏开发工具包？](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/intro/introduction)

## See also

[XGameRuntimeInitialize](/reference/system/xgameruntimeinit/functions/xgameruntimeinitialize)
[XGameRuntimeInit](/reference/system/xgameruntimeinit/xgameruntimeinit_members)
[使用 Gaming Runtime 开发新标题](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/pc-dev/overviews/gr-developing-new-titles-on-gamecore)


## Related topics

- [XGameRuntimeInit](/zh-CN/reference/system/xgameruntimeinit/xgameruntimeinit_members.md)
- [XGameRuntimeInitialize](/zh-CN/reference/system/xgameruntimeinit/functions/xgameruntimeinitialize.md)
- [XGameRuntimeInitializeWithOptions](/zh-CN/reference/system/xgameruntimeinit/functions/xgameruntimeinitializewithoptions.md)
- [将 GDK 集成到自定义 C/C++ 引擎](/zh-CN/build/gdk-and-engines/custom-engine.md)
- [错误代码](/zh-CN/reference/errorcodes.md)
