string MainWindowTitle() // Gets the caption of the main window of the process. private void button1_Click(object sender, EventArgs e) { listBox1.Visible = false; listBox1.Items.Clear(); try { Process[] prlist = Process.GetProcessesByName(textBox1.Text); // return list of processes with matching name foreach (Process p in prlist) { listBox1.Items.Add( p.MainWindowHandle.ToString().PadRight(10) + p.MainWindowTitle); } listBox1.Visible = true; } catch (Exception ex) { throw ex; } } A complete application is attached below. |
