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

# IGameInputDevice::GetDeviceId

> 取得可唯一識別輸入裝置的應用程式本機識別碼。

取得可唯一識別輸入裝置的應用程式本機識別碼。

## 語法

```cpp theme={null}
void GetDeviceId(
    APP_LOCAL_DEVICE_ID* deviceId
);
```

### 參數

*deviceId*   \_Out\_\
類型：[APP\_LOCAL\_DEVICE\_ID](https://docs.xbox.com/zh-TW/reference/system/xuser/structs/app_local_device_id.md)\*

接收裝置的應用程式本機識別碼。

### 傳回值

類型：void

## 備註

裝置識別碼是應用程式本機識別碼：一個可唯一識別裝置的 256 位元雜湊值。只要裝置連接至相同的 USB 連接埠，即使在應用程式的多次執行或系統重新開機之間，指定裝置的此識別碼也會保持不變。此雜湊部分是根據呼叫端應用程式和系統特有的資訊產生，因此同一個裝置在不同的應用程式中會有不同的識別碼。

由於此識別碼是穩定的，您可以將其儲存起來以記住某個裝置 (例如使用者慣用的控制器)，之後再呼叫 [IGameInput::FindDeviceFromId](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinput/methods/igameinput_finddevicefromid.md) 查詢相符的裝置物件。

對於屬於複合裝置上多個介面之一的裝置，請使用 [IGameInputDevice::GetDeviceRootId](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getdevicerootid.md) 取得根裝置的識別碼。如果裝置不屬於複合裝置，則裝置識別碼和根裝置識別碼會相同。

在 GameInput v3 及更早版本中，此資訊可從 [IGameInputDevice::GetDeviceInfo](https://docs.xbox.com/zh-TW/reference/input/gameinput/deprecated/interfaces/igameinputdevice/methods/igameinputdevice_getdeviceinfo.md) 所傳回 [GameInputDeviceInfo](https://docs.xbox.com/zh-TW/reference/input/gameinput/deprecated/structs/gameinputdeviceinfo.md) 結構的 `deviceId` 成員取得。

## 需求

**標頭：** GameInput.h

**程式庫：** gameinput.lib

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

## 另請參閱

[GameInput 概觀](https://docs.xbox.com/zh-TW/build/core-features/common/input/overviews/input-overview.md)\
[IGameInputDevice](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/igameinputdevice.md)\
[IGameInputDevice::GetDeviceRootId](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getdevicerootid.md)\
[IGameInput::FindDeviceFromId](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinput/methods/igameinput_finddevicefromid.md)\
[APP\_LOCAL\_DEVICE\_ID](https://docs.xbox.com/zh-TW/reference/system/xuser/structs/app_local_device_id.md)

## 版本歷程記錄

| 版本 | 變更 |
| - | - |
| **v4** | 已推出。 |


## Related topics

- [IGameInputDevice::GetDeviceRootId](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getdevicerootid.md)
- [IGameInputDevice::IsConnected](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_isconnected.md)
- [IGameInputDevice::GetContainerId](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontainerid.md)
- [IGameInputDevice::GetVendorId](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getvendorid.md)
- [IGameInputDevice::GetProductId](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getproductid.md)
