0

I have written C++ dll. In this DLL I'm hooking two WIN API, GetClipboardData & SetClipboardData. So I want to check whether the data which is going to be inserted into clipboard in SetClipboardData is from PrintScreen ?

In SetClipboardData WIN API, how I can find if data is coming from PrintScreen ?

-Thanks Ajit

Serge Wautier
  • 21,494
  • 13
  • 69
  • 110
Ajit Medhekar
  • 1,018
  • 1
  • 10
  • 39
  • 2
    You could check whether the data contains a `CF_DIB` of the same resolution as the screen? Or just hook the PrintScr key. – Jonathan Potter Dec 15 '15 at 07:48
  • You cannot do this reliably. The information does not exist. Why would you care where the data comes from? – David Heffernan Dec 15 '15 at 09:07
  • Sounds like an [XY problem](http://meta.stackexchange.com/q/66377/205381) to me. What problem are you really trying to solve? – IInspectable Dec 15 '15 at 09:47
  • I want to just block PrintScreen when some file is open. I tried SetWindowsHookEx() fro keyboard hook. But it's not working on 64 bit machine for 32 bit process. – Ajit Medhekar Dec 17 '15 at 06:50

1 Answers1

2

You can't really know for sure. But if the clipboard contains BITMAP and DIB, does NOT contain TEXT, and..... a call to GetClipboardOwner returns NULL, then it's a pretty good bet. Hooking the PrintScreen key can be helpful, but I would only use it for correlation. i.e. note the timestamp of when PrintScreen was pressed, note the timestamp of the clipboard event, and if they are close, it's likely that the Bitmap on the clipboard, with NULL owner, was produced by the PrintScreen key.

Chris Thornton
  • 15,620
  • 5
  • 37
  • 62