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

# XInputGetBatteryInformation

> XInputGetBatteryInformation

# XInputGetBatteryInformation

检索无线控制器的电池类型和充电状态。

<a id="syntaxSection" />

## 语法

```cpp theme={null}
DWORD XInputGetBatteryInformation(  
         DWORD dwUserIndex,  
         BYTE devType,  
         XINPUT_BATTERY_INFORMATION* pBatteryInformation  
)  
```

<a id="parametersSection" />

### 参数

*dwUserIndex*   \_In\_\
类型：DWORD

与设备关联的玩家索引；取值范围为 0 到 `XUSER_MAX_COUNT - 1`。

*devType*   \_In\_\
类型：BYTE

要查询的与 *dwUserIndex* 关联的设备类型。必须为 `BATTERY_DEVTYPE_GAMEPAD` 或 `BATTERY_DEVTYPE_HEADSET`。

*pBatteryInformation*   \_Out\_\
类型：[XINPUT\_BATTERY\_INFORMATION](/reference/input/xinputongameinput/structs/xinput_battery_information)\*

指向 [XINPUT\_BATTERY\_INFORMATION](/reference/input/xinputongameinput/structs/xinput_battery_information) 对象的指针，用于接收电池信息。

<a id="retvalSection" />

### 返回值

类型：DWORD

如果函数成功，返回值为 `ERROR_SUCCESS`。

<a id="remarksSection" />

## 备注

*pBatteryInformation* 中返回的值指定了电池的类型及其充电状态。仅当设备具有已知的电池类型时，充电状态才有效。

有关详细信息，请参阅 [XInputOnGameInput 包装器](/build/core-features/common/input/porting/input-porting-xinput#xinputWrapperSection)。

<a id="requirementsSection" />

## 要求

**头文件：** XInputOnGameInput.h

**库：** xgameruntime.lib

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

<a id="seealsoSection" />

## 另请参阅

[从 XInput 移植到 GameInput](/build/core-features/common/input/porting/input-porting-xinput)\
[XInputOnGameInput](/reference/input/xinputongameinput/xinputongameinput_members)


## Related topics

- [XINPUT_BATTERY_INFORMATION](/zh-CN/reference/input/xinputongameinput/structs/xinput_battery_information.md)
- [XInputOnGameInput](/zh-CN/reference/input/xinputongameinput/xinputongameinput_members.md)
- [IGameInputDevice::GetBatteryState](/zh-CN/reference/input/gameinput/deprecated/interfaces/igameinputdevice/methods/igameinputdevice_getbatterystate.md)
- [GameInputBatteryState](/zh-CN/reference/input/gameinput/deprecated/structs/gameinputbatterystate.md)
- [GameInputBatteryStatus](/zh-CN/reference/input/gameinput/deprecated/enums/gameinputbatterystatus.md)
