Skip to content

Instantly share code, notes, and snippets.

@mikeobrien
Created June 28, 2011 05:34
Show Gist options
  • Save mikeobrien/1050559 to your computer and use it in GitHub Desktop.
Save mikeobrien/1050559 to your computer and use it in GitHub Desktop.
[DllImport("user32.dll")]
static extern int GetWindowThreadProcessId(IntPtr windowHandle, IntPtr processId);
public void Close()
{
var threadId = GetWindowThreadProcessId(Browser.hWnd, IntPtr.Zero);
Process.GetProcessesByName("iexplore").First(x => x.Threads.Cast<ProcessThread>().Any(y => y.Id == threadId)).Kill();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment