-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cs
More file actions
29 lines (19 loc) · 734 Bytes
/
main.cs
File metadata and controls
29 lines (19 loc) · 734 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
using System.Runtime.InteropServices;
Console.WriteLine(GetProcessLockingClipboard().Id);
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr GetOpenClipboardWindow();
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr GetClipboardOwner();
[DllImport("user32.dll", SetLastError = true)]
static extern int GetWindowThreadProcessId(IntPtr hWnd, out int lpdwProcessId);
private static Process GetProcessLockingClipboard()
{
IntPtr handle = GetOpenClipboardWindow();
int error = Marshal.GetLastWin32Error();
Console.WriteLine(handle);
Console.WriteLine(error);
int processId;
GetWindowThreadProcessId(handle, out processId);
return Process.GetProcessById(processId);
}