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

# XGameRuntimeInitialize

> XGameRuntimeInitialize

# XGameRuntimeInitialize

Gaming Runtime을 초기화합니다.

## 구문

```cpp theme={null}
HRESULT XGameRuntimeInitialize(  
)  
```

### 매개 변수

없음.

### 반환 값

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

성공하면 **S\_OK**를 반환하고, 그렇지 않으면 오류 코드를 반환합니다. 오류 코드 목록은 [오류 코드](/reference/errorcodes)를 참조하세요. Gaming Runtime 라이브러리(xgameruntime.dll)를 찾지 못해 함수가 실패하면 반환 값은 **E\_GAMERUNTIME\_DLL\_NOT\_FOUND**로 설정됩니다.

## 설명

게임에서 Gaming Runtime 기능을 사용하려면 먼저 **XGameRuntimeInitialize** 함수를 호출하여 Gaming Runtime을 초기화합니다. **XGameRuntimeInitialize** 함수를 최대한 일찍, 일반적으로 게임의 진입점 함수 내에서 호출합니다. 마찬가지로, 게임이 종료되기 전이지만 가능한 한 늦게 [XGameRuntimeUninitialize](/reference/system/xgameruntimeinit/functions/xgameruntimeuninitialize) 함수를 호출하여 Gaming Runtime을 초기화 해제합니다.

게임 런타임에 컴파일 및 링크되는 각 바이너리는 시작 초기에 **XGameRuntimeInitialize**를 호출해야 합니다. 여기에는 게임 바이너리와 Gaming Runtime 기능을 사용하는 DLL 형태의 미들웨어가 포함됩니다. **XGameRuntimeInitialize** 함수의 내부에서는 타이틀이 컴파일된 모든 인터페이스의 버전이 확인되며 일치하는 런타임 서비스를 초기화하는 데 사용됩니다. Gaming Runtime의 두 가지 다른 버전 사이에서, 함수가 추가되거나 제거되거나 드물게 호환성이 깨지는 동작 변경이 있을 수 있습니다. 각 구성 요소에서 **XGameRuntimeInitialize**를 호출하면 같은 프로세스 내에서 로드되는 두 개의 다른 바이너리에서 두 개의 다르고 호환되지 않는 버전의 게임 런타임에 대해 컴파일하는 것과 같은 빌드 구성 문제를 감지하는 데 도움이 됩니다. 이러한 호환되지 않는 구성은 **E\_GAMERUNTIME\_VERSION\_MISMATCH** 오류를 발생시킵니다.

다음 예제는 Visual Studio의 **Direct3D 12 Desktop Game** 템플릿을 기반으로 하는 게임의 진입점 함수 내에서 **XGameRuntimeInitialize** 및 [XGameRuntimeUninitialize](/reference/system/xgameruntimeinit/functions/xgameruntimeuninitialize) 함수를 사용하는 방법을 보여 줍니다. **XGameRuntimeInitialize** 함수는 **Game** 개체가 인스턴스화되고 등록되기 전에 호출되며, **XGameRuntimeUninitialize** 함수는 **Game** 개체가 재설정된 후 진입점 함수가 반환되기 전에 호출됩니다.

```cpp theme={null}
// Entry point
int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    // Initialize the Gaming Runtime before
    // performing any other activity.
    if (FAILED(XGameRuntimeInitialize()))
        return 1;

    if (!XMVerifyCPUSupport())
        return 1;

    g_game = std::make_unique<Game>();

    // Register class and create window
    {
        // Code omitted for brevity.
        ...
    }

    // Main message loop
    MSG msg = {};
    while (WM_QUIT != msg.message)
    {
        // Code omitted for brevity.
        ...
    }

    g_game.reset();

    // Uninitialize the Gaming Runtime after
    // all other activity has been completed.
    XGameRuntimeUninitialize();

    return (int) msg.wParam;
}
```

## 요구 사항

**헤더:** XGameRuntimeInit.h

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

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

## 개념 문서

* [Microsoft Game Development Kit이란?](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/intro/introduction)

## 함께 보기

[XGameRuntimeUninitialize](/reference/system/xgameruntimeinit/functions/xgameruntimeuninitialize)\
[XGameRuntimeInitializeWithOptions](/reference/system/xgameruntimeinit/functions/xgameruntimeinitializewithoptions)\
[XGameRuntimeInit](/reference/system/xgameruntimeinit/xgameruntimeinit_members)\
[XGameRuntime 구조체](/reference/system/xgameruntimeinit/Structures/xgameruntimeoptions)\
[XGameRuntime 열거형](/reference/system/xgameruntimeinit/Enumerations/xgameruntimegameconfigsource)\
[Gaming Runtime을 사용한 새 타이틀 개발](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/pc-dev/overviews/gr-developing-new-titles-on-gamecore)


## Related topics

- [XGameRuntimeInitializeWithOptions](/ko/reference/system/xgameruntimeinit/functions/xgameruntimeinitializewithoptions.md)
- [XGameRuntimeUninitialize](/ko/reference/system/xgameruntimeinit/functions/xgameruntimeuninitialize.md)
- [XGameRuntimeInit](/ko/reference/system/xgameruntimeinit/xgameruntimeinit_members.md)
- [XSystemGetRuntimeInfo](/ko/reference/system/xsystem/functions/xsystemgetruntimeinfo.md)
- [XGameRuntimeIsFeatureAvailable](/ko/reference/system/xgameruntimefeature/functions/xgameruntimeisfeatureavailable.md)
