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

# XUserGetGamertag

> XUserGetGamertag

# XUserGetGamertag

Retrieves the gamertag for a specific user.

## Syntax

```cpp theme={null}
HRESULT XUserGetGamertag(  
         XUserHandle user,
         XUserGamertagComponent gamertagComponent,
         size_t gamertagSize,  
         char* gamertag,  
         size_t* gamertagUsed  
)  
```

### Parameters

*user*   \_In\_\
Type: XUserHandle

A handle to the user to retrieve the gamertag for.

*gamertagComponent*   \_In\_\
Type: [XUserGamertagComponent](/reference/system/xuser/enums/xusergamertagcomponent)

Type of gamertag to retrieve.

*gamertagSize*   \_In\_\
Type: size\_t

Size in bytes of the buffer in the *gamertag* parameter.

*gamertag*   \_Out\_writes\_bytes\_to\_(gamertagSize,*gamertagUsed)\
Type: char*

Contains the gamertag for a specific user.

*gamertagUsed*   \_Out\_opt\_\
Type: size\_t\*

Contains the amount of the buffer for holding the gamertag.

### Return value

Type: HRESULT

HRESULT success or error code.

| Return Code                                 | Description                                                                                                                                                                     |
| ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| S\_OK                                       | The operation succeeded.                                                                                                                                                        |
| E\_GAMEUSER\_RESOLVE\_USER\_ISSUE\_REQUIRED | The user must use a UI to resolve the issue. Call [XUserResolveIssueWithUiAsync](/reference/system/xuser/functions/xuserresolveissuewithuiasync) to display the UI to the user. |
| E\_INSUFFICIENT\_BUFFER                     | The size of the buffer indicated by *gamertagSize* is not large enough to hold the requested component.                                                                         |
| E\_INVALIDARG                               | Invalid *gamertagComponent* provided.                                                                                                                                           |

For a list of error codes, see [Error Codes](/reference/errorcodes).

## Remarks

To retrieve the user ID for a specific user, call [XUserGetId](/reference/system/xuser/functions/xusergetid).

To retrieve the state of a specific user, call [XUserGetState](/reference/system/xuser/functions/xusergetstate).

To retrieve the age group for a specific user, call [XUserGetAgeGroup](/reference/system/xuser/functions/xusergetagegroup).

## Requirements

**Header:** XUser.h

**Library:** xgameruntime.lib

**Supported platforms:** Windows, Steam Deck, XBOX One family consoles and XBOX Series consoles

## See also

[XUser](/reference/system/xuser/xuser_members)

[XUserGetId](/reference/system/xuser/functions/xusergetid)

[XUserGetState](/reference/system/xuser/functions/xusergetstate)

[XUserGetAgeGroup](/reference/system/xuser/functions/xusergetagegroup)
