LogonUI, PowerShell and Command Prompt windows invisible when using GetDC to capture a screenshot in Hyper-V Server

Adam Bajac 1 Reputation point
2021-08-20T22:43:07.83+00:00

Hi all,

As the title says, I am capturing screenshots of the desktop using GdiPlus through examples found pretty commonly on the internet (GetDC, BitBlt, etc). Combining this with the OpenInputDesktop and SetDesktopThread API even allows me to capture the secure desktop, which is exactly what I want. However, I've noticed that with Hyper-V Server 2016 and above, the logon UI, and any cmd or powershell Windows are not included in my screencap. I'm assuming it's a permissions thing, but my application taking the screenshots is already running as local system.

This does not happen outside of Hyper-V Server, and applications such as teamviewer are still able to capture those windows. Can anyone illuminate me as to why this behavior occurs in Hyper-V Server?

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,446 questions
Hyper-V
Hyper-V
A Windows technology providing a hypervisor-based virtualization solution enabling customers to consolidate workloads onto a single server.
2,568 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,559 questions
0 comments No comments
{count} votes