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

# XUserGetLocalId

> XUserGetLocalId

# XUserGetLocalId

사용자의 고유한 게임 세션 ID를 가져옵니다.

## 구문

```cpp theme={null}
HRESULT XUserGetLocalId(  
         XUserHandle user,  
         XUserLocalId* userLocalId  
)  
```

### 매개변수

*user*   \_In\_\
형식: XUserHandle

로컬 ID를 가져올 사용자에 대한 핸들입니다.

*userLocalId*   \_Out\_\
형식: [XUserLocalId\*](/reference/system/xuser/structs/xuserlocalid)

사용자의 고유한 게임 세션 ID를 포함합니다.

### 반환값

형식: HRESULT

HRESULT 성공 또는 오류 코드입니다.\
오류 코드 목록은 [Error Codes](/reference/errorcodes)를 참조하십시오.

## 설명

특정 사용자의 사용자 ID를 가져오려면 [XUserGetId](/reference/system/xuser/functions/xusergetid)를 호출합니다.

특정 사용자의 상태를 가져오려면 [XUserGetState](/reference/system/xuser/functions/xusergetstate)를 호출합니다.

특정 사용자의 연령 그룹을 가져오려면 [XUserGetAgeGroup](/reference/system/xuser/functions/xusergetagegroup)을 호출합니다.

**XUserLocalId**는 게임 세션 내에서 사용자를 고유하게 식별합니다. **XUserHandle**을 복제하는 경우 두 핸들 모두 동일한 **XUserLocalId**를 유지합니다. 게임 세션이 끝나면 동일한 사용자가 다음 세션 동안 다른 **XUserLocalId**를 가질 수 있습니다. 이러한 ID를 게임 세션 간에 사용자를 추적하는 데 사용하지 마십시오.

다음 예제는 **XUserLocalId**를 사용하여 사용자의 기본 오디오 엔드포인트를 가져오는 방법을 보여줍니다.

```cpp theme={null}
HRESULT GetAudioDeviceAssociation(
    IMMDeviceEnumerator* audioDeviceEnumerator,
    XUserLocalId user,
    XUserDefaultAudioEndpointKind defaultAudioEndpointKind,
    _Outptr_result_maybenull_ IMMDevice** endpoint)
{
    wchar_t audioDeviceId[XUserAudioEndpointMaxUtf16Count];
    RETURN_IF_FAILED_WITH_EXPECTED(XUserGetDefaultAudioEndpointUtf16(user, defaultAudioEndpointKind, std::size(audioDeviceId), audioDeviceId, nullptr), E_NOTFOUND);

    return audioDeviceEnumerator->GetDevice(audioDeviceId, endpoint);
}

HRESULT GetAudioAssociations()
{
    Mwrl::ComPtr<IMMDeviceEnumerator> audioDeviceEnumerator;

    RETURN_IF_FAILED(CoCreateInstance(
        __uuidof(MMDeviceEnumerator),
        nullptr,
        CLSCTX_ALL,
        __uuidof(IMMDeviceEnumerator),
        (void**)&audioDeviceEnumerator));

    XUserLocalId userLocalId;
    RETURN_IF_FAILED(XUserGetLocalId(_handle.get(), &userLocalId));

    {
        wil::unique_cotaskmem_string id;
        Mwrl::ComPtr<IMMDevice> device;
        if (SUCCEEDED(GetAudioDeviceAssociation(audioDeviceEnumerator.Get(), userLocalId, XUserDefaultAudioEndpointKind::CommunicationRender, &device)))
        {
            RETURN_IF_FAILED(device->GetId(&id));
        }
        appLog.AddLog("Preferred render communication device id: %S\n", id.get());
    }

    {
        wil::unique_cotaskmem_string id;
        Mwrl::ComPtr<IMMDevice> device;
        if (SUCCEEDED(GetAudioDeviceAssociation(audioDeviceEnumerator.Get(), userLocalId, XUserDefaultAudioEndpointKind::CommunicationCapture, &device)))
        {
            RETURN_IF_FAILED(device->GetId(&id));
        }
        appLog.AddLog("Preferred capture communication device id: %S\n", id.get());
    }

    return S_OK;
}
```

## 요구 사항

**헤더:** XUser.h

**라이브러리:** xgameruntime.lib

**지원되는 플랫폼:** Windows, Steam Deck, XBOX One 계열 콘솔 및 XBOX Series 콘솔

## 함께 보기

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

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

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

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


## Related topics

- [XUserLocalId](/ko/reference/system/xuser/structs/xuserlocalid.md)
- [사용자 및 입력 장치](/ko/build/core-features/common/user/users-input-devices.md)
- [사용자 ID 및 XUser](/ko/build/core-features/common/user/player-identity-xuser.md)
- [XUser](/ko/reference/system/xuser/xuser_members.md)
- [GDK용 Unity C# API 래퍼](/ko/build/gdk-and-engines/unity/unity-api-wrappers.md)
