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

# XInputGetDeviceId

> XInputGetDeviceId

# XInputGetDeviceId

检索指定控制器的设备 ID。

<a id="syntaxSection" />

## 语法

```cpp theme={null}
DWORD XInputGetDeviceId(  
         DWORD dwUserIndex,  
         APP_LOCAL_DEVICE_ID * pDeviceId  
)  
```

<a id="parametersSection" />

### 参数

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

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

*pDeviceId*   \_Out\_\
类型：APP\_LOCAL\_DEVICE\_ID\*

指定用户索引处的设备 ID。

<a id="retvalSection" />

### 返回值

类型：DWORD

如果函数成功检索到设备 ID，则返回 `ERROR_SUCCESS`。

如果未连接控制器，函数将返回 `ERROR_DEVICE_NOT_CONNECTED`。

如果函数失败，则返回 Win32 错误代码。

<a id="remarksSection" />

## 备注

应用程序本地设备 ID 用于唯一标识某个设备，即使在游戏或系统重启后依然有效。有关详细信息，请参阅 [设备 ID](/build/core-features/common/input/overviews/input-devices#deviceIdsSection)。

有关使用 XInputOnGameInput 的详细信息，请参阅 [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

- [APP_LOCAL_DEVICE_ID](/zh-CN/reference/system/xuser/structs/app_local_device_id.md)
- [用户与输入设备](/zh-CN/build/core-features/common/user/users-input-devices.md)
- [XInputOnGameInput](/zh-CN/reference/input/xinputongameinput/xinputongameinput_members.md)
- [从 XInput 移植到 GameInput](/zh-CN/build/core-features/common/input/porting/input-porting-xinput.md)
- [IGameInputDevice::GetRawDeviceFeature](/zh-CN/reference/input/gameinput/deprecated/interfaces/igameinputdevice/methods/igameinputdevice_getrawdevicefeature.md)
