Thursday, June 06, 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.

QR: Inline image 1