0

I would like to make a process selection with an open file dialog gui, so the user can pick which process they want to terminate.

this.openFileDialog1.FileName = "FileName";

I've found this in System.Windows.Forms;. Any ideas on how can I solve my problem?

Pera16
  • 15
  • 5
  • 1
    What are you having a problem with? Getting a list of running processes? – gunr2171 Jan 08 '21 at 21:32
  • 1
    Does this answer your question? [How can I list all processes running in Windows?](https://stackoverflow.com/questions/648410/how-can-i-list-all-processes-running-in-windows) – gunr2171 Jan 08 '21 at 21:32
  • I want to get a list or running processes but in a gui, so user can pick a process out of the list. – Pera16 Jan 08 '21 at 21:33
  • 1
    Also, a OpenFileDialog control is for selecting files from your hard drive, not anything else. – gunr2171 Jan 08 '21 at 21:33
  • @Pera16 If you're asking for a ready built GUI for selecting running processes you probably won't find any open source implementations for that. You'll have to build that yourself. – Xerillio Jan 09 '21 at 12:25

1 Answers1

0
  1. In windows forms add ListView to form.
  2. Change View to Details and add 2 columns to this ListView.
  3. Paste code to Form_Load for example.
foreach(Process process in Process.GetProcesses())
{
     ListViewItem item = new ListViewItem(process.ProcessName);
     item.SubItems.Add(new ListViewItem.ListViewSubItem(item, process.Id.ToString()));
     listViewProcesses.Items.Add(item);
}
  1. Add using System.Diagnostics;

  2. To kill process make:

Process.GetProcessById(Convert.ToInt32(listViewProcesses.SelectedItems[0].SubItems[1].Text)).Kill();
Kuba_Z2
  • 54
  • 1
  • 6