The best place to ask questions on Windows.Graphics.Capture is here: https://github.com/robmikh/Win32CaptureSample/issues/33#issuecomment-774807345
ApiInformation::IsApiContractPresent is the one you need.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi Team,
My Windows C++ desktop application is required to run on all versions of Windows 10 operating systems, and I do want to use Windows.Graphics.Capture APIs to capture other application's window. I Know that Windows.Graphics.Capture is only supported on Windows 10, version 1803 or above. So how to dynamically call/or not call Windows.Graphics.Capture APIs based on Windows 10 version. For example, at the run time, if my application detects that OS is Windows 10 version below 1803, my app will not load the Windows.Graphics.Capture API dll and will not call Windows.Graphics.Capture APIs; if version is 1803 or above, my app will load Windows.Graphics.Capture API dll and call Windows.Graphics.Capture APIs.
Thanks for your help for resolving this issue,
The best place to ask questions on Windows.Graphics.Capture is here: https://github.com/robmikh/Win32CaptureSample/issues/33#issuecomment-774807345
ApiInformation::IsApiContractPresent is the one you need.
Just added two screenshots here, one is win10 version on my machine, the other is runtime error message when running on Windows 10, version 1607. Thanks for your help again.
Maybe you can do a test like this (I cannot test if it fails as I have Windows 10 1909) :
BOOL bOK = FALSE;
HMODULE hInst = LoadLibrary(L"CoreMessaging.dll");
if (hInst)
{
FARPROC pFunction = (FARPROC&)pFunction = GetProcAddress(hInst, "CreateDispatcherQueueController");
if (pFunction)
{
static IGraphicsCaptureSessionStatics* pStatics;
HRESULT hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Graphics_Capture_GraphicsCaptureSession).Get(), IID_PPV_ARGS(&pStatics));
if (SUCCEEDED(hr))
bOK = TRUE;
}
}
At beginning :
#include <winrt/Windows.Foundation.h>
#include <winrt/base.h>
#include <wrl\wrappers\corewrappers.h> // HString::MakeReference
using namespace Microsoft::WRL::Wrappers;
using namespace winrt;
#include <roapi.h>
#include <windows.graphics.capture.h>
using namespace ABI::Windows::Graphics::Capture;
#pragma comment (lib, "windowsapp")