I have a peculiar error where some process occasionally appears to be using the clipboard when my application goes to handle copy & paste operations. There are some ret
I've wrapped my solution into an easy-to-use method (and some declarations):
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr GetOpenClipboardWindow();
[DllImport("user32.dll", SetLastError = true)]
static extern int GetWindowThreadProcessId(IntPtr hWnd, out int lpdwProcessId);
private static Process GetProcessLockingClipboard()
{
int processId;
GetWindowThreadProcessId(GetOpenClipboardWindow(), out processId);
return Process.GetProcessById(processId);
}
Enjoy!