2

I know how to write and use windows hook DLLs to capture things such as window messages on a window. What I need to do is capture any copy (Control+C or other method) done on the system in any application. Is there a quick simple way to do this using windows hooks?

Rocky Pulley
  • 22,531
  • 20
  • 68
  • 106

1 Answers1

6

You're looking for the SetClipboardViewer function.

Anytime the clipboard contents change, the most recent window to have been registered via this function (or the related ChangeClipboardChain) will receive a WM_DRAWCLIPBOARD message.

Its an applications responsibility to pass the message down the chain for to other registered viewers, as well as to un-register itself during shutdown.

This will be much more reliable than trying to hook ctrl+c.

Kevin Montrose
  • 22,191
  • 9
  • 88
  • 137