Prevent a Screen Capture


I'm writing an application, and I'm trying to prevent the user to grab a screen capture using the Print Screen button, or a third-party tool.
What is the best way? It doens't has to be full waterproof, just dummyproof.
The more secure, the better.

Can I use MFC with some hooks?

Thanks in advance,
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


 Yes you should use SetWindowsHookEx and CallNextHookEx

  You can hook the keyboard and stop ctrl and alt printscreen getting through by not calling the next hook function.
  With third party apps is could be difficult because to capture the screen simply requires you to create a compatible bitmap with the desktop an do a could hook into the bitblt API see this article


   You might also want to monitor the clipboard as useually the image is placed there during this operation.

   Let me know which line of attack you'd like to pursue :)

eXecutiVeAuthor Commented:
The article of bugslayer points to Smooth Working Set (I don't know what that is).

Can you give me some more information about that hook into bitblt? What exactly should I override or something? I think we're on the right track.

Thanks in advance!
Not an answer, but I am curious...
I have racked my brain and can't think of a single reasonable purpose for such a function.  Why do you need it?
-- Dan
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.


DisableLowLevelKeys sample disables Alt+Tab, Ctrl+Esc and other key combinations. You can use this sample, jusr change the keys you want to disable in the LowLevelKeyboardProc function.
eXecutiVeAuthor Commented:
To DanRollins:
I have to design such tool for some architects who want to preview images to their customers, but the danger is that the customer doesn't pay the architect, but runs away with the jpeg inside.

(Sorry for my bad english, I'm aware if it hehe)

Is there anybody with some more info on the bitblt hook?

Thanks in advance!
  If you take a look a HFIBN_Test.cpp in the bugslayer example  

Here are the changes you need to make to the test program for BitBlt

Here is the BitBlt function

BOOL My_NewBitBlt (
  HDC hdcDest, // handle to destination DC
  int nXDest,  // x-coord of destination upper-left corner
  int nYDest,  // y-coord of destination upper-left corner
  int nWidth,  // width of destination rectangle
  int nHeight, // height of destination rectangle
  HDC hdcSrc,  // handle to source DC
  int nXSrc,   // x-coordinate of source upper-left corner
  int nYSrc,   // y-coordinate of source upper-left corner
  DWORD dwRop  // raster operation code
    // Handle the Call

  typedef int (__stdcall *BITBLTPROC)(HDC ,int ,int ,int ,int ,HDC,int ,int ,DWORD) ;

   BITBLTPROC pfnOrigBitBlt = NULL ;

    stToHook.szFunc = "BitBltA" ;  // none unicode version
    stToHook.pProc  = (PROC)My_NewBitBlt;  // this is your new proc for BitBlt

    DWORD uiCount ;

    BOOL bRet =
        HookImportedFunctionsByName ( GetModuleHandle ( NULL ) ,
                                      "GDI32.DLL"             ,
                                      1                        ,
                                      &stToHook                ,
                                      (PROC*)&pfnOrigBitBlt    ,
                                      &uiCount                  ) ;

You will need to use HookImportedFunctionByName.Cpp and BugSlayerUtil.h

Build a sample program first and let us know how it goes
eXecutiVeAuthor Commented:
Getting closer...

The hook works now fine (I've tested it with a button that does a BitBlt), but when I use a screen capture program, my hook isn't called. They seem to use another function.

Anybody some ideas?

Thank you very much william campbell

Do you have access to the Resource Kit for Win2k? There is a program called APIMON.EXE. Perhaps you could use this to find out what API's they are using. There is also StretchBlt!
eXecutiVeAuthor Commented:
I think they do a bitblt from the desktop window and it seems I'm not able to catch that call.
But there must be a way I believe.
Can't I modify the onDraw function? Or clear every 100miliseconds  the clipboard or something?

I'm really desperate
Thank you in advance for your time


 I think I might have an idea.

 Create an app with the image as part of the resource (in a dll) when the app is launched it goes full screen and displays the image. If the app looses focus close the app immediately (they are trying to get to another app). Or if ctrl or alt are pressed immediately close the app, do this via the keyboard hook. What do you think?


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
You *might* find some sort of kludgy workaround, but the only valid solution to this problem is to not send a usable image to somebody who will steal it from you.  

I recommend embedding a "watermark" (say the words "CONFIDENTIAL, Do Not COPY") writen in dim grey text in a diagonal lines all over the "background" of the image.  And obviously, place a bright, clear, copyright notice at several places in the image.

You could also show them an image in which the resolution had been so compormised that the result would provide a reasonable idea of what the final would look like, but still not be usable.  

Another idea is to do what map-makers have done for years... intentionally embed subtle mistakes in the image.  If the image gets passed around, the mistakes act as a signature.  You can sue the person who infringes your copyright and get a nice new home in Beverly Hills, California and never need to work another day in your life.

-- Dan

 You could also create a screen saver of the image and lock the workstation with a password :) Doesnt prevent them from taking a picture with a digital camera however :p
eXecutiVeAuthor Commented:
Is there a way using directX and overlay or something so the screen can't be captured?

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.