Domanda

I've sadly inherited a shockingly bad application that randomly posts text to the clipboard.

Is there anyway in C# I can write an application/dll etc to stop process_name.exe accessing the clipboard?

È stato utile?

Soluzione

Use AddClipboardFormatListener. Get the hWnd of the offending process's main window and pass it to the method. Now, will you be able to completely lock the clipboard, I don't know. But you'll probably be able to blank the clipboard or revert to the previous value at least when you detect that the offending app. has posted something to it.

More details here

But you should not really mess with the clipboard unless you only read from it. Locking/modifying it can cause a whole lot of other problems.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top