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

# XAppCaptureTakeScreenshot

> XAppCaptureTakeScreenshot

# XAppCaptureTakeScreenshot

Takes a screenshot.

## Syntax

```cpp theme={null}
HRESULT XAppCaptureTakeScreenshot(  
         XUserHandle requestingUser,  
         XAppCaptureTakeScreenshotResult* result  
)  
```

### Parameters

*requestingUser*   \_In\_\
Type: XUserHandle

Handle representing the user requesting the screenshot.

*result*   \_Out\_\
Type: [XAppCaptureTakeScreenshotResult\*](/reference/system/xappcapture/structs/xappcapturetakescreenshotresult)

Results of the screenshot returned.

### Return value

Type: HRESULT

Function result.

## Remarks

<Note>This function isn't safe to call on a time-sensitive thread. For more information, see [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads).\
\[!NOTE]
This function isn't supported on XBOX Game Streaming. See the Requirements section below to see which platforms support it.\
\[!NOTE]
Older screenshots will be deleted when allotted space is filled to make room for new screenshots. Use [PLS](/reference/system/xpersistentlocalstorage/xpersistentlocalstorage_members) (Persistent Local Storage), connected storage (e.g. [XGameSave](/reference/system/xgamesave/xgamesave_members) or [XGameSaveFiles](/reference/system/xgamesavefiles/xgamesavefiles_members)), or a similar storage system in order to retain screenshots for a set period of time.</Note>

**XAppCaptureTakeScreenshot** takes a screenshot as if the user triggered it. This will show a toast and save the game screenshot.
If the game is running in SDR, a single file is generated. If the game is running in HDR, two files are generated, one in HDR and one in SDR format.
The screenshot(s) may be uploaded automatically to XBOX Live depending on the user preference. Once the screenshot was taken successfully, the resulting file can be read by opening the screenshot stream with [XAppCaptureOpenScreenShotStream](/reference/system/xappcapture/functions/xappcaptureopenscreenshotstream) and reading the screenshot with [XAppCaptureReadScreenshotStream](/reference/system/xappcapture/functions/xappcapturereadscreenshotstream). Both of these function will require that you use the local Id returned in the [XAppCaptureTakeScreenshotResult](/reference/system/xappcapture/structs/xappcapturetakescreenshotresult) returned from this function.

```cpp theme={null}
XAppCaptureTakeScreenshotResult takeScreenshotResult = {0};
XUserHandle user = nullptr;
/* See XUserAddAsync, XUserAddResult on how to initialize XUserHandle */
bool hasHDR = false;

LOG_IF_FAILED(XAppCaptureTakeScreenshot(user, &takeScreenshotResult));

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

appLog.AddLog("LocalId %s (%s)\n", takeScreenshotResult.localId, hasHDR ? "SDR & HDR" : "SDR only");
```

## Requirements

**Header:** XAppCapture.h

**Library:** xgameruntime.lib

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

## Conceptual documentation

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

## See also

[GameDVR Overview](/build/console-features/game-dvr/gamedvr-broadcast)\
[XAppCapture Members](/reference/system/xappcapture/xappcapture_members)\
[XAppCaptureOpenScreenShotStream](/reference/system/xappcapture/functions/xappcaptureopenscreenshotstream)\
[XAppCaptureReadScreenShotStream](/reference/system/xappcapture/functions/xappcapturereadscreenshotstream)\
[XAppCaptureCloseScreenshotStream](/reference/system/xappcapture/functions/xappcaptureclosescreenshotstream)\
[XAppCaptureTakeScreenshotResult](/reference/system/xappcapture/structs/xappcapturetakescreenshotresult)


## Related topics

- [XAppCaptureTakeScreenshotResult](/reference/system/xappcapture/structs/xappcapturetakescreenshotresult.md)
- [XAppCaptureScreenshotStream](/reference/system/xappcapture/structs/xappcapturescreenshotstream.md)
- [XAppCaptureOpenScreenshotStream](/reference/system/xappcapture/functions/xappcaptureopenscreenshotstream.md)
- [XAppCaptureTakeDiagnosticScreenshot](/reference/system/xappcapture/functions/xappcapturetakediagnosticscreenshot.md)
- [XAppCaptureReadScreenshotStream](/reference/system/xappcapture/functions/xappcapturereadscreenshotstream.md)
