From 30748dd916f4f3442316825e8ecf715e03c44092 Mon Sep 17 00:00:00 2001 From: ns6089 <61738816+ns6089@users.noreply.github.com> Date: Wed, 10 Jul 2024 15:14:17 +0300 Subject: [PATCH] Check API before trying to disable border on WGC capture (#2825) --- src/platform/windows/display_wgc.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/platform/windows/display_wgc.cpp b/src/platform/windows/display_wgc.cpp index 577dd2d49f0..1df60fcd8e0 100644 --- a/src/platform/windows/display_wgc.cpp +++ b/src/platform/windows/display_wgc.cpp @@ -11,6 +11,7 @@ #include #include +#include #include namespace platf { @@ -19,6 +20,7 @@ namespace platf { namespace winrt { using namespace Windows::Foundation; + using namespace Windows::Foundation::Metadata; using namespace Windows::Graphics::Capture; using namespace Windows::Graphics::DirectX::Direct3D11; @@ -120,7 +122,12 @@ namespace platf::dxgi { return -1; } try { - capture_session.IsBorderRequired(false); + if (winrt::ApiInformation::IsPropertyPresent(L"Windows.Graphics.Capture.GraphicsCaptureSession", L"IsBorderRequired")) { + capture_session.IsBorderRequired(false); + } + else { + BOOST_LOG(warning) << "Can't disable colored border around capture area on this version of Windows"; + } } catch (winrt::hresult_error &e) { BOOST_LOG(warning) << "Screen capture may not be fully supported on this device for this release of Windows: failed to disable border around capture area: [0x"sv << util::hex(e.code()).to_string_view() << ']';