microsoft / Windows.UI.Composition-Win32-Samples

Windows.UI.Composition Win32 Samples
MIT License
469 stars 186 forks source link

Unhandled exception at 0x00007FFD3B8B9129 (KernelBase.dll) in CreateCaptureItemForWindow #93

Closed leonzio01 closed 2 years ago

leonzio01 commented 2 years ago

OS: windows server 2019 IDE: VS2019 WinSDK: 10.0.19041.0

the demo app was built successfully but crashed when i selected a window

Unhandled exception at 0x00007FFD3B8B9129 (KernelBase.dll) in ScreenCaptureforHWND.exe: 0xC000041D: An unhandled exception was encountered during a user callback.

exception at: if (result == impl::error_no_interface) { throw hresult_no_interface(take_ownership_from_abi); }

but this demo could work if my os was windows 10

so i was wondering if this api need some adpation for windows server?

robmikh commented 2 years ago

There is a known issue with previous versions of Windows where passing a non-capturable window to CreateForWindow results in an unhandled exception. This was fixed in Windows 11 (possibly in Win10 10.0.20348.0, I'd have to double check).

leonzio01 commented 2 years ago

There is a known issue with previous versions of Windows where passing a non-capturable window to CreateForWindow results in an unhandled exception. This was fixed in Windows 11 (possibly in Win10 10.0.20348.0, I'd have to double check).

but i tried several versions of SDK including 19041, 20348 and 22000, all of them crashed if the os is windows server 2019. And, no crash happens if the os is windows 10 for all these three versions of SDK.

Another clue is that for windows server 2019, i can run your another demo(https://github.com/robmikh/Win32CaptureSample) which calls GraphicsCapturePicker instead of CreateCaptureItemForWindow.

that is: Windows Server 2019, CreateCaptureItemForWindow fails at SDK 19041, 20348 and 22000, but GraphicsCapturePicker succeeds at all SDKs. Windows 10 always succeeds.

robmikh commented 2 years ago

The SDK version will not change the behavior of the API. The API's implementation is shipped with the operating system, the SDK only contains headers and metadata.

leonzio01 commented 2 years ago

so what can i do in order to solve this problem for windows server2019?

leonzio01 commented 2 years ago

The SDK version will not change the behavior of the API. The API's implementation is shipped with the operating system, the SDK only contains headers and metadata.

hello again, could you help me to confirm if CreateCaptureItemForWindow can work on windows server 2019 or not? accually, on windows server2019, the demo will fail at this line: // capture.interop.h line 9 auto interop_factory = activation_factory.as\<IGraphicsCaptureItemInterop>();

and throw an exception: if (result == impl::error_no_interface) { throw hresult_no_interface(take_ownership_from_abi); } it seems like the interface IGraphicsCaptureItemInterop is not available on windows server 2019

but same codes will succeed on windows 10

robmikh commented 2 years ago

Windows Server 2019 is based off of Windows 10 build 17763. The IGraphicsCaptureItemInterop interface was introduced in build 18363.

You'll need a newer version of Windows Server to use this interface.