See this article, close the specified IE instance: http://www.c-sharpcorner.com/code/2002/mar/captrunieinstances.asp you think about another way to make a first modification registry: hkey_local_machine // system // CurrentControlSet // Service // PerfProc // under the Performance: Disable Performance Counters value of 0 to obtain the current process system, added to the listBox: System.Diagnostics.Process [] processOnComputer = System.Diagnostics.Process.GetProcesses ( ); foreach (System.Diagnostics.Process p in processOnComputer) {this.listBox1.Items.Add (p.ProcessName);} close a specified process: System.Diagnostics.Process [] process = System.Diagnostics.Process. GetProcesSbyName (this.listbox1.selected); foreach (system.diagnostics.process p in process) {p.kill ();} But this will turn off all instances of the process, such as if you have opened multiple IEs, Will close all IE windows. Next, a particular IE instance declare an arraylist: arraylist (); get all instances of the specified process, put it in a listbox, put the Handle of the main window in ArrayList: System.Diagnostics. Process [] processOnComputer = System.Diagnostics.Process.GetProcessesByName (this.listBox1.SelectedItem.ToString ()); foreach (System.Diagnostics.Process p in processOnComputer) {this.listBox2.Items.Add (p.MainWindowTitle); / / Display the title of the main form of the main form for the title of the main form "} in listbox;
The comparison of the host window of the main window of the specified process is closed if you meet, if you meet, turn off system.diagnostics.process [] process = system.diagnostics.Process.getProcessesbyName (this.ListBox1.selectedItem.toString ()); Foreach System.Diagnostics.Process P in process) {if (p.mainwindowhandle == (system.intptr) (WindowHandle [this.listbox2.selected ") {p.kill (); this.listbox2.Items.Removeat (this. ListBox2.selectedIndex;}} This can turn off the process of the main form, but there is no main form of the main form.