-1

I want to trigger a piece of code to run as soon as a 'copy' command is executed on Windows. Let's say I want to perform some operations as soon as the user tries to copy a file. Is there any way to detect the 'copy' operation on Windows?

V.I.L
  • 19
  • 4
  • Copying is not an atomic operation that can be identified and monitored at the file-system level. It's simply reading the file data and some or all metadata. – Eryk Sun Nov 08 '18 at 12:03
  • Yes, this is possible. That's what anti-malware software does. What is your question? – IInspectable Nov 08 '18 at 18:55

1 Answers1

0

You may monitor the clipboard (see Creating a Clipboard Format Listener) and check if there is an object with format CF_HDROP in it. But it will not tell you when the clipboard paste operation actually started.

This also will not cover copying which does not involve clipboard, like direct file_read/file_write loop in a File Manager application. For this you may monitor changes in the file system (see How can I monitor a Windows directory for changes?) but it will not tell you where was the file copied from, just where was it pasted to.

xmojmr
  • 8,073
  • 5
  • 31
  • 54