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

# IGameInput::UnregisterCallback

> IGameInput::UnregisterCallback

# IGameInput::UnregisterCallback

移除一个回调方法。该方法将不再被调用，且在 UnregisterCallback 完成后，您可以安全地释放与回调函数关联的资源。

## 语法

```cpp theme={null}
bool UnregisterCallback(
    GameInputCallbackToken callbackToken
);
```

### 参数

*callbackToken*   \_In\_\
类型:GameInputCallbackToken

要注销的回调函数的令牌。该令牌在最初通过 [IGameInput::RegisterDeviceCallback](/reference/input/gameinput/interfaces/igameinput/methods/igameinput_registerdevicecallback) 注册函数时生成。

### 返回值

类型:bool

如果回调已成功注销，则返回 True。

## 注解

[IGameInput::StopCallback](/reference/input/gameinput/interfaces/igameinput/methods/igameinput_stopcallback) 方法与 **IGameInput::UnregisterCallback** 方法略有不同。调用任一方法都可确保关联的回调不再被分发。但是，在 UnregisterCallback 函数成功返回之前，释放与回调关联的任何资源（例如卸载承载回调函数的 DLL）都是不安全的。因此，无法在已注册的回调函数内部注销该回调，尝试这样做将触发致命断言。但是，在回调函数内部取消回调是安全的。

以下 C++ 示例演示如何在游戏手柄或键盘断开连接时获得通知。

[Input API 概述](/build/core-features/common/input/overviews/input-overview)\
[IGameInput](/reference/input/gameinput/interfaces/igameinput/igameinput)\
[IGameInput::RegisterDeviceCallback](/reference/input/gameinput/interfaces/igameinput/methods/igameinput_registerdevicecallback)\
[IGameInput::RegisterReadingCallback](/reference/input/gameinput/interfaces/igameinput/methods/igameinput_registerreadingcallback)\
[IGameInput::RegistersystemButtonCallback](/reference/input/gameinput/interfaces/igameinput/methods/igameinput_registersystembuttoncallback)

## 版本历史

| 版本     | 变更  |
| ------ | --- |
| **v0** | 引入。 |


## Related topics

- [IGameInput::StopCallback](/zh-CN/reference/input/gameinput/interfaces/igameinput/methods/igameinput_stopcallback.md)
- [IGameInput::RegisterDeviceCallback](/zh-CN/reference/input/gameinput/interfaces/igameinput/methods/igameinput_registerdevicecallback.md)
- [IGameInput::RegisterReadingCallback](/zh-CN/reference/input/gameinput/interfaces/igameinput/methods/igameinput_registerreadingcallback.md)
- [IGameInput::RegisterKeyboardLayoutCallback](/zh-CN/reference/input/gameinput/interfaces/igameinput/methods/igameinput_registerkeyboardlayoutcallback.md)
- [GameInput API 版本管理](/zh-CN/build/core-features/common/input/overviews/input-versioning.md)
