> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XInputGetBatteryInformation

> XInputGetBatteryInformation

# XInputGetBatteryInformation

擷取無線控制器的電池類型和充電狀態。

## 語法

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

### 參數

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

與裝置相關聯之玩家的索引；值的範圍為 0 到 `XUSER_MAX_COUNT - 1`。

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

要查詢之與 *dwUserIndex* 相關聯的裝置類型。必須為 `BATTERY_DEVTYPE_GAMEPAD` 或 `BATTERY_DEVTYPE_HEADSET`。

*pBatteryInformation*   \_Out\_\
類型：[XINPUT\_BATTERY\_INFORMATION](https://docs.xbox.com/zh-TW/reference/input/xinputongameinput/structs/xinput_battery_information.md)\*

指向接收電池資訊之 [XINPUT\_BATTERY\_INFORMATION](https://docs.xbox.com/zh-TW/reference/input/xinputongameinput/structs/xinput_battery_information.md) 物件的指標。

### 傳回值

類型：DWORD

如果函式成功，傳回值為 `ERROR_SUCCESS`。

## 備註

*pBatteryInformation* 中傳回的值會指定電池類型及其充電狀態。充電狀態僅對具有已知電池類型的裝置有效。

如需詳細資訊，請參閱 [XInputOnGameInput 包裝函式](https://docs.xbox.com/zh-TW/build/core-features/common/input/porting/input-porting-xinput.md#xinputWrapperSection)。

## 需求

**標頭：** XInputOnGameInput.h

**程式庫：** xgameruntime.lib

**支援的平台：** XBOX One 系列主機和 XBOX Series 主機

## 另請參閱

[從 XInput 移植到 GameInput](https://docs.xbox.com/zh-TW/build/core-features/common/input/porting/input-porting-xinput.md)\
[XInputOnGameInput](https://docs.xbox.com/zh-TW/reference/input/xinputongameinput/xinputongameinput_members.md)


## Related topics

- [XINPUT_BATTERY_INFORMATION](https://docs.xbox.com/zh-TW/reference/input/xinputongameinput/structs/xinput_battery_information.md)
- [XInputOnGameInput (API 內容)](https://docs.xbox.com/zh-TW/reference/input/xinputongameinput/xinputongameinput_members.md)
- [IGameInputDevice::GetBatteryState (已淘汰)](https://docs.xbox.com/zh-TW/reference/input/gameinput/deprecated/interfaces/igameinputdevice/methods/igameinputdevice_getbatterystate.md)
- [GameInputBatteryState (已淘汰)](https://docs.xbox.com/zh-TW/reference/input/gameinput/deprecated/structs/gameinputbatterystate.md)
- [GameInputBatteryStatus (已淘汰)](https://docs.xbox.com/zh-TW/reference/input/gameinput/deprecated/enums/gameinputbatterystatus.md)
