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

# XSystemGetAppSpecificDeviceId

> XSystemGetAppSpecificDeviceId

# XSystemGetAppSpecificDeviceId

從主機傳回呼叫端遊戲 ID 專屬的唯一值。

## 語法

```cpp theme={null}
HRESULT XSystemGetAppSpecificDeviceId(  
         size_t appSpecificDeviceIdSize,  
         char* appSpecificDeviceId,  
         size_t* appSpecificDeviceIdUsed  
)  
```

### 參數

*appSpecificDeviceIdSize*   \_In\_\
類型：size\_t

*appSpecificDeviceId* 的大小 (以位元組為單位)。此值必須等於或大於 XSystem.h 中定義的 **XSystemAppSpecificDeviceIdBytes**
常數。

*appSpecificDeviceId*   \_Out\_writes\_bytes\_to\_(appSpecificDeviceIdSize, \*appSpecificDeviceIdUsed)\
類型：char\*

將接收應用程式專屬裝置 ID 的字元緩衝區。

*appSpecificDeviceIdUsed*   \_Out\_opt\_\
類型：size\_t\*

傳回之 *appSpecificDeviceIdUsed* 緩衝區的大小 (以位元組為單位)。

### 傳回值

類型：[HRESULT](https://learn.microsoft.com/openspecs/windows_protocols/ms-erref/0642cb2f-2075-4469-918c-4441e69c548a)

如果成功，則傳回 **S\_OK**；否則傳回錯誤碼。如需錯誤碼清單，請參閱[錯誤碼](/zh-TW/reference/errorcodes)。
如果函式因 *appSpecificDeviceIdSize* 設定為小於 **XSystemAppSpecificDeviceIdBytes** 的值而失敗，
傳回值會設定為 **HRESULT\_FROM\_WIN32(ERROR\_INSUFFICIENT\_BUFFER)**。

## 備註

<Note>在時間敏感執行緒上呼叫此函式並不安全。如需詳細資訊，請參閱</Note>
[時間敏感執行緒](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)。

如果因錯誤而無法取得應用程式專屬裝置識別碼，
將會傳回常數字串 "00000000000000000000000000000000000000000000"。

如果您的應用程式使用單一登入 (SSO)，您應該使用 XSTS SSO 權杖的成對 ID，而不是此函式
傳回的 ID。

## 需求

**標頭：** XSystem.h

**程式庫：** xgameruntime.lib

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

## 另請參閱

[啟用您的開發套件 (NDA 主題)](/zh-TW/home/setup-install/devkits/setup/activating-dev-kit)\
[XSystemGetXboxLiveSandbodId](/zh-TW/reference/system/xsystem/functions/xsystemgetxboxlivesandboxid)\
[XSystem](/zh-TW/reference/system/xsystem/xsystem_members)


## Related topics

- [XSystemGetAppSpecificDeviceId](/ja-jp/reference/system/xsystem/functions/xsystemgetappspecificdeviceid.md)
- [XSystem](/reference/system/xsystem/xsystem_members.md)
- [XSystemGetConsoleId](/reference/system/xsystem/functions/xsystemgetconsoleid.md)
- [APP_LOCAL_DEVICE_ID](/reference/system/xuser/structs/app_local_device_id.md)
