1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Getting list of running processes on my comp

Discussion in 'C#' started by Jazerix, Aug 28, 2010.

  1. Jazerix

    Jazerix New Member

    Joined:
    Aug 28, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hey there, so basicly I'm writing a little application that will kill some processes and some junk programs running in the background. Yea i know this can be done in task manager aswell, but I want to learn ^^.

    So, I want a button called "Get all running proccesses", when u click that button all processes should get added to a dropdown box, so the user can select the process in the dropdown menu. right now i got this command:
    Code:
    foreach (System.Diagnostics.Process p in System.Diagnostics.Process.GetProcessesByName(textBox1.Text))
                {
                    try
                    {
                        p.Kill();
                        p.WaitForExit();
                        progressBar1.Value = 100;
                        label1.ForeColor = System.Drawing.Color.Green;
                        label1.Text = "Process Successfully Killed";
                        timer1.Start();
                        textBox1.ResetText();
                    }
                    catch (Win32Exception)
                    {
    
                    }
                    catch (InvalidOperationException)
                    {
    
                    }
    it will kill the text entered in the textbox, so i just want to replace the text box with a dropdown menu :P, any thoughts on how i could do this?

    Edit: also, is there any way i can make label1 it say "couldnt find process" or something similar if it could find the process? :)

    Kind Regards
    -Jazerix
     

Share This Page