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

擷取指定控制器的裝置識別碼。

<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\*

位於指定使用者索引之裝置的識別碼。

<a id="retvalSection" />

### 傳回值

類型：DWORD

如果函式成功擷取裝置識別碼，會傳回 `ERROR_SUCCESS`。

如果控制器未連接，函式會傳回 `ERROR_DEVICE_NOT_CONNECTED`。

如果函式失敗，會傳回 Win32 錯誤碼。

<a id="remarksSection" />

## 備註

應用程式本機裝置識別碼可唯一識別裝置，即使在遊戲或系統重新啟動後也是如此。如需詳細資訊，請參閱[裝置識別碼](/zh-TW/build/core-features/common/input/overviews/input-devices#deviceIdsSection)。

如需使用 XInputOnGameInput 的詳細資訊，請參閱 [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

- [XInputGetDeviceId](/reference/input/xinputongameinput/functions/xinputgetdeviceid.md)
- [Users and input devices](/build/core-features/common/user/users-input-devices.md)
- [APP_LOCAL_DEVICE_ID](/reference/system/xuser/structs/app_local_device_id.md)
