Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top