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

# XUserFindUserByLocalId

> XUserFindUserByLocalId

# XUserFindUserByLocalId

擷取特定本機使用者識別碼的使用者控制代碼。

## 語法

```cpp theme={null}
HRESULT XUserFindUserByLocalId(  
         XUserLocalId userLocalId,  
         XUserHandle* handle  
)  
```

### 參數

*userLocalId*   \_In\_\
類型：[XUserLocalId](/zh-TW/reference/system/xuser/structs/xuserlocalid)

要取得其使用者的本機識別碼。

*handle*   \_Out\_\
類型：XUserHandle\*

包含與特定本機使用者識別碼相關聯之使用者的控制代碼。

### 傳回值

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

類型：HRESULT

HRESULT 成功或錯誤碼。

| 傳回碼 | 描述 |
| - | - |
| S\_OK | 作業成功。 |
| HRESULT\_FROM\_WIN32(ERROR\_NOT\_FOUND) | 找不到使用者。 |

## 備註

對於從 **XUser** API (包括 **XUserFindUserByLocalId**) 擷取的每個 **XUserHandle** 控制代碼，您都必須
呼叫 [XUserCloseHandle](/zh-TW/reference/system/xuser/functions/xuserclosehandle) 來關閉該控制代碼。呼叫 Get / Find 函式之後，控制代碼的參考計數會增加。

若要擷取特定本機使用者識別碼的使用者控制代碼，請呼叫 XUserFindUserByLocalId。

若要擷取本機使用者的 XBOX 使用者識別碼 (XUID)，請呼叫 [XUserFindUserById](/zh-TW/reference/system/xuser/functions/xuserfinduserbyid)。

若要擷取特定裝置識別碼的使用者識別碼，請呼叫 [XUserFindForDevice](/zh-TW/reference/system/xuser/functions/xuserfindfordevice)。

## 需求

**標頭：** XUser.h

**程式庫：** xgameruntime.lib

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

## 概念文件

* [時間敏感執行緒](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## 另請參閱

[XUser](/zh-TW/reference/system/xuser/xuser_members)

[XUserFindUserById](/zh-TW/reference/system/xuser/functions/xuserfinduserbyid)

[XUserFindForDevice](/zh-TW/reference/system/xuser/functions/xuserfindfordevice)


## Related topics

- [XUserFindUserByLocalId](/reference/system/xuser/functions/xuserfinduserbylocalid.md)
- [XUserFindUserById](/reference/system/xuser/functions/xuserfinduserbyid.md)
