Created
November 21, 2011 08:28
-
-
Save koffeinfrei/1382028 to your computer and use it in GitHub Desktop.
Gets the process that locks the clipboard (i.e. openened but didn't close it)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.InteropServices; | |
using System.Diagnostics; | |
namespace ConsoleApplication1 | |
{ | |
public class Program | |
{ | |
[DllImport("user32.dll")] | |
static extern IntPtr GetOpenClipboardWindow(); | |
[DllImport("user32.dll", SetLastError = true)] | |
static extern int GetWindowThreadProcessId(IntPtr hWnd, out int | |
lpdwProcessId); | |
public static void Main(string[] args) | |
{ | |
IntPtr hwnd = GetOpenClipboardWindow(); | |
if (hwnd != IntPtr.Zero) | |
{ | |
int processId; | |
GetWindowThreadProcessId(hwnd, out processId); | |
Process p = Process.GetProcessById(processId); | |
Console.WriteLine(p.Modules[0].FileName); | |
} | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment