1
votes

I need to capture a snapshots/screenshots of the specific window (HWND) that is using HW acceleration and record them to a video stream.

While using BitBlt or PrintWindow I'm able to capture image data only if this window is not HW accelerated, else I'm getting a black texture.

Tried using User32.dll's undocumented DwmGetDxSharedSurface to get the DirectX surface handle. But it fails with an error:

ERROR_GRAPHICS_PRESENT_REDIRECTION_DISABLED - desktop windowing management subsystem is off

(Edit: Fails for certain applications, i.e. "calculator.exe")

Tried using Dwmapi.dll's undocumented functions DwmpDxUpdateWindowSharedSurface and DwmpDxGetWindowSharedSurface. I've managed to retrieve what looks like a valid DirectX surface handle. (it's d3dFormat, width and height information was valid) Dx's OpenSharedResource was not complaining and managed to create a valid ID3D11Texture2D. Problem is.. all bytes are zeros (getting a black texture). I might be doing something wrong here or.. undocumented DWM functionas does not work anymore on Windows 10...

Edit: I'm able to get image data for some applications like Windows explorer, Paint, etc, but for some like i.e. Slack i get all zeros/black image.

Edit: When capturing i.e. VLC, I get this: enter image description here

Question: Is there any other way to capture image data of the HW accelerated window?

Note: I don't want to capture the entire desktop.

1
Which technology is the application using? Does it only fail on UWP apps? Does the DWM thumbnail API work or is it also blank?Anders
@Anders I was testing with windows calculator.exe. DWM thumbnail is able to capture and show the duplicated "thumbnail" image in my window. But DwmGetDxSharedSurface (User32.dll) fails with the specified error.Gediminas
Did you find the solution? I am having the same issueuser1428926
@user1428926 I did not, if you will, please let me know.Gediminas
@Gediminas do you still have the code for DwmGetDxSharedSurface() or DwmpDxGetWindowSharedSurface()trickymind

1 Answers

2
votes

You can use PrintWindow with nFlags=2 Or use Magnification API (exclude windows) Or try to hack dwm.exe.