kambamsu kambamsu - 1 month ago 22
C# Question

How to lock the clipboard?

I was wondering if there is anyway to lock and unlock the clipboard from C#. Basically, I'd be writing something into it and I do not want anyone else to write to it before I pick up my stuff.

How can I do this?

Answer

The OpenClipboard() API function, followed by EmptyClipboard() locks the clipboard until CloseClipboard is called. You should probably pass a window handle of a window in the target process. No idea if this will actually work. Visit pinvoke.net for the required declarations.

Comments