-3

I'm creating a native win32 gui application for generating, storing and displaying passwords. I want to detect if someone is trying to screenshot my window or if someone gets a handle to it's DC.

Is it possible to detect GetDC, BitBlt, GetPixel, billions of ways to get hwnd of my window and others methods to access my application's video memory?

Demiler
  • 67
  • 3
  • 9
  • FWIW, I do not believe that's possible. Consider, for example, the possibility that your programs runs inside a VM or a remote session on another machine, and the user grabs all or part of the screen on that. I don't see a universal way for your app to detect that. – 500 - Internal Server Error Sep 23 '21 at 21:50
  • 3
    Ban cameras too – David Heffernan Sep 23 '21 at 21:56
  • You're going to make sure that you prevent users from having cameras or smartphones in the same area where your program runs, too. Let us know how that works out for you. Also be aware that there are other reasons than a screen capture where someone needs to find your window's handle as well, like automation or needing to set the position in relation to another application. Make sure your hook can tell the difference. Again, let us know how that works out for you. Oh, yeah, and apps that decide to get an HWND or DC for the entire screen instead and just capture your app that way. Good luck. – Ken White Sep 23 '21 at 22:51
  • 5
    With all that said, see [this answer](https://stackoverflow.com/a/22745115/62576) for an API call that can help prevent screen captures from some API calls. – Ken White Sep 23 '21 at 22:55

1 Answers1

1

Preventing a user from having control over their machine is evil but I guess if you must... SetWindowDisplayAffinity

Anders
  • 97,548
  • 12
  • 110
  • 164