> ## 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](/zh-TW/reference/input/xinputongameinput/structs/xinput_battery_information)\*

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

<a id="retvalSection" />

### 傳回值

類型：DWORD

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

<a id="remarksSection" />

## 備註

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

如需詳細資訊，請參閱 [XInputOnGameInput 包裝函式](/zh-TW/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](/zh-TW/build/core-features/common/input/porting/input-porting-xinput)\
[XInputOnGameInput](/zh-TW/reference/input/xinputongameinput/xinputongameinput_members)


## Related topics

- [XInputGetBatteryInformation](/reference/input/xinputongameinput/functions/xinputgetbatteryinformation.md)
- [XINPUT_BATTERY_INFORMATION](/reference/input/xinputongameinput/structs/xinput_battery_information.md)
