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

# XSystemGetDeviceType

> XSystemGetDeviceType

# XSystemGetDeviceType

傳回對應目前使用中裝置的 [XSystemDeviceType](/zh-TW/reference/system/xsystem/enums/xsystemdevicetype) 值。

## 語法

```cpp theme={null}
XSystemDeviceType XSystemGetDeviceType(  
)  
```

### 參數

無。

### 傳回值

類型：[XSystemDeviceType](/zh-TW/reference/system/xsystem/enums/xsystemdevicetype)

對應目前使用中裝置的 [XSystemDeviceType](/zh-TW/reference/system/xsystem/enums/xsystemdevicetype) 列舉值。

<Note>
  此函式沒有明確的錯誤狀態，但如果無法判斷使用中的裝置類型，將會傳回 **XSystemDeviceType::Unknown** 值。
</Note>

## 備註

此查詢會傳回主機模式，而非實際的硬體類型，這表示開發人員主機在遊戲輪詢時，可能會偽裝成不同的裝置類型。

<Note>
  針對 XBOX One 系列建置的 Microsoft Game Development Kit (GDK) 遊戲，不會傳回
  XBOX Series 主機範圍內的裝置代碼，除非 [MicrosoftGame.config](/zh-TW/reference/system/microsoftgameconfig/microsoftgameconfig-schema) 檔案中的 XboxCompatibility 設定設為 Scarlett。相反地，它會根據目前裝置
  傳回 XBOX One 系列的代碼。

  | 實際裝置 / 模式 | 針對 XBOX One 系列建置 | 針對 XBOX Series 主機建置 |
  | - | - | - |
  | XBOX Series X 開發套件 | XboxOneXDevkit | XboxScarlettDevkit |
  | XBOX Series X<br />Anaconda 分析模式 | XboxOneX | XboxScarlettAnaconda |
  | XBOX Series S<br />Lockhart 分析模式<br />XBOX Series S 測試套件 | XboxOneS | XboxScarlettLockhart |

  如需目標裝置系列用法的詳細資訊，請參閱
  [MicrosoftGame.config 概觀](/zh-TW/build/core-features/common/game-config/MicrosoftGameConfig-Overview)。
</Note>

可以在呼叫 [XGameRuntimeInitialize](/zh-TW/reference/system/xgameruntimeinit/functions/xgameruntimeinitialize) 之前執行此查詢，以便在早期遊戲初始化期間使用。

此範例會取得目前使用中的裝置類型。如果是在開發套件上執行，則會執行自訂程式碼以在遊戲內啟用開發人員功能。

```cpp theme={null}
const XSystemDeviceType deviceType = XSystemGetDeviceType(); 
const bool deviceIsDevkit = 
    deviceType == XSystemDeviceType::XboxOneXDevkit || 
    deviceType == XSystemDeviceType::XboxScarlettDevkit; 
 
if (deviceIsDevkit) 
{ 
    EnableGameSpecificDevkitFeatures(); 
}
```

## 需求

**標頭：** XSystem.h

**程式庫：** xgameruntime.lib

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

## 另請參閱

[XSystemDeviceType](/zh-TW/reference/system/xsystem/enums/xsystemdevicetype)\
[XSystem](/zh-TW/reference/system/xsystem/xsystem_members)


## Related topics

- [XSystemGetDeviceType](/reference/system/xsystem/functions/xsystemgetdevicetype.md)
- [XSystemDeviceType](/reference/system/xsystem/enums/xsystemdevicetype.md)
- [Intelligent Delivery: device specifiers](/build/core-features/common/packaging/intelligentdelivery-device.md)
- [XSystem](/reference/system/xsystem/xsystem_members.md)
