June 3rd, 2013

How do I make it more difficult for somebody to take a screenshot of my window?

Ultimately, you can’t stop somebody from ignoring the words Confidential at the top of a document and whipping out a digital camera and taking a picture of the screen. But at least starting in Windows 7 you can make it a little more difficult.

Take our scratch program and add this one line:

SetWindowDisplayAffinity(hwnd, WDA_MONITOR);
    ShowWindow(hwnd, nShowCmd);
    …

Assuming you have the Desktop Window Manager enabled, you will find that attempting to capture our scratch program in a screenshot or via the Snipping Tool will result in black pixels.

Remember, this is just an obstacle, not a security measure. If somebody is determined to get the pixels, this step is only going to slow them down a little. (For example, on Windows 7, they can simply disable the Desktop Window Manager.) But it’s handy for reducing the likelihood of an accidental breach of confidential information.

Pre-emptive hate: “DRM is evil!” My response to you: If you don’t like DRM, then don’t buy DRM-protected content. If you don’t like IRM, then don’t read IRM-protected documents. If you don’t like Blu-Ray, then don’t buy Blu-Ray DVDs.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.