XUserFindForDevice

Retrieves the user ID for a specific device ID.

Syntax

HRESULT XUserFindForDevice(  
         const APP_LOCAL_DEVICE_ID* deviceId,  
         XUserHandle* handle  
)  

Parameters

deviceId   _In_
Type: APP_LOCAL_DEVICE_ID*

The ID of the device.
handle   _Out_
Type: XUserHandle*

Contains the XUID for the local user.

Return value

Type: HRESULT

Returns S_OK if successful; otherwise, returns an error code. For a list of error codes, see Error Codes.

Remarks

Note

This function isn't safe to call on a time-sensitive thread. For more information, see Time-sensitive threads.

The association between user and device can change for many reasons:

  • The user signs out from the console.
  • Someone uses the input device to select a different user in the Account Picker.

To receive a notification when the user-device association changes, call XUserRegisterForDeviceAssociationChanged to get an XUserDeviceAssociationChangedCallback.

Note

XUserFindForDevice cannot return a user handle to a user that hasn't been signed in with a call to XUserAddAsync. See Users and input devices for more information.

Requirements

Header: XUser.h

Library: xgameruntime.lib

Supported platforms: Windows, Xbox One family consoles and Xbox Series consoles

See also

XUser

XUserRegisterForDeviceAssociationChanged

XUserDeviceAssociationChangedCallback