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

# XAppCaptureOpenScreenshotStream

> XAppCaptureOpenScreenshotStream

# XAppCaptureOpenScreenshotStream

スクリーンショット ストリームを開きます。

## 構文

```cpp theme={null}
HRESULT XAppCaptureOpenScreenshotStream(  
         const char* localId,  
         XAppCaptureScreenshotFormatFlag screenshotFormat,  
         XAppCaptureScreenshotStreamHandle* handle,  
         uint64_t* totalBytes  
)  
```

### パラメーター

*localId*   \_In\_\
型: char\*

[XAppCaptureTakeScreenshot](/reference/system/xappcapture/functions/xappcapturetakescreenshot) を呼び出した後に [XAppCaptureTakeScreenshotResult](/reference/system/xappcapture/structs/xappcapturetakescreenshotresult) で返されるスクリーンショットのローカル ID です。

*screenshotFormat*   \_In\_\
型: [XAppCaptureScreenshotFormatFlag](/reference/system/xappcapture/enums/xappcapturescreenshotformatflag)

[XAppCaptureTakeScreenshot](/reference/system/xappcapture/functions/xappcapturetakescreenshot) を呼び出した後に [XAppCaptureTakeScreenshotResult](/reference/system/xappcapture/structs/xappcapturetakescreenshotresult) で返されるスクリーンショット フォーマット フラグです。

*handle*   \_Out\_\
型: XAppCaptureScreenshotStreamHandle\*

ストリームを開いた結果として返されるスクリーンショット ストリーム ハンドルです。

*totalBytes*   \_Out\_opt\_\
型: uint64\_t\*

ストリーム内の合計バイト数です。

### 戻り値

型: HRESULT

関数の結果です。

## 解説

<Note>この関数は、時間依存スレッドで呼び出しても安全ではありません。 詳細については、「[Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)」を参照してください。</Note>

スクリーンショットはゲーム パーティションからはアクセスできないため、ユーザーが撮影した、または [XAppCaptureTakeScreenshot](/reference/system/xappcapture/functions/xappcapturetakescreenshot) で撮影したスクリーンショットを取得するためには、ストリームを開く必要があります。 [XAppCaptureTakeScreenshot](/reference/system/xappcapture/functions/xappcapturetakescreenshot) は結果として *localID* を返し、これはこの関数で適切なスクリーンショットを取得するために使用されます。 *localID* は、スクリーンショットがディスクに保持されている限り有効です。 本体でスクリーンショットが保存される容量には限りがあります。 割り当てられた容量がいっぱいになると、古いスクリーンショットは削除されます。 これにより、open screenshot 関数が localID を見つけられない可能性があります。 ストリームを開いた後、[XAppCaptureReadScreenShotStream](/reference/system/xappcapture/functions/xappcapturereadscreenshotstream) でスクリーンショットを読み取ることができます。 最後に、メモリ リークを避けるため、すべてのストリームは [XAppCaptureCloseScreenshotStream](/reference/system/xappcapture/functions/xappcaptureclosescreenshotstream) で閉じる必要があります。

```cpp theme={null}
XAppCaptureTakeScreenshotResult takeScreenshotResult = {0};
XAppCaptureScreenshotStreamHandle handle = nullptr;
UINT64 totalBytesToRead = 0;
XAppCaptureScreenshotFormatFlag screenshotFormat = XAppCaptureScreenshotFormatFlag::SDR;
bool hdrAvailable = false;

/* ... obtain takeScreenshotResult with XAppCaptureTakeScreenshot. Refer to corresponding documentation ... */

hdrAvailable = static_cast<bool>(takeScreenshotResult.availableScreenshotFormats & XAppCaptureScreenshotFormatFlag::HDR);

/* Note: It is optional to obtain the HDR screenshot, if HDR is available. You will need to call XAppCaptureOpenScreenshotStream twice to obtain both SDR and HDR screenshots */
if (hdrAvailable)
{
    screenshotFormat = XAppCaptureScreenshotFormatFlag::HDR;
}

if (FAILED_LOG(XAppCaptureOpenScreenshotStream(takeScreenshotResult.localId, screenshotFormat, &handle, &totalBytesToRead)))
{
    return;
}

appLog.AddLog("%I64d bytes returned\n", totalBytesToRead);

/* You must always call XAppCaptureCloseScreenshotStream on an open XAppCaptureScreenshotStreamHandle to avoid a memory leak */
if (handle != nullptr)
{
    XAppCaptureCloseScreenshotStream(handle);
}

```

## 要件

**ヘッダー:** XAppCapture.h

**ライブラリ:** xgameruntime.lib

**サポートされているプラットフォーム:** Windows、XBOX One ファミリー本体、XBOX Series 本体

## 概念ドキュメント

* [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## 関連項目

[GameDVR の概要](/build/console-features/game-dvr/gamedvr-broadcast)\
[XAppCapture メンバー](/reference/system/xappcapture/xappcapture_members)\
[XAppCaptureReadScreenShotStream](/reference/system/xappcapture/functions/xappcapturereadscreenshotstream)\
[XAppCaptureTakeScreenshot](/reference/system/xappcapture/functions/xappcapturetakescreenshot)\
[XAppCaptureCloseScreenshotStream](/reference/system/xappcapture/functions/xappcaptureclosescreenshotstream)
