View Single Post
Old June 10th, 2009   #33 (permalink)
S.T.A.R.S.
 
S.T.A.R.S.'s Avatar
 
Join Date: Jan 2006
Location: Planet Earth...
Posts: 593
Rauntec......................do you have any idea how much you just helped me?????????????????Let me tell you...
A LOT DUDE!!!!!!!!!!!!!!!!
Thanks man I will never forget you this.Never!
Anyway the code you gave me for showing the currently active processes is working perfect.And then I wanted to make the end process button too,(and I will admit that I am not a very good programmer),and after 1 hour of thinking like hell,I managed to get my code working.The button1 click event is for showing the currently active processes and the button2 click event is ending any of the selected process.Here is the code:

privatevoid button1_Click(object sender, System.EventArgs e)
{
listBox1.Items.Clear();
Process[] procs=Process.GetProcesses(Environment.MachineName .ToString());
foreach(Process process in procs)
{
if(process.MainWindowTitle.Length>0)
{
listBox1.Items.Add(process.MainModule.ModuleName);
}
}
}
privatevoid button2_Click(object sender, System.EventArgs e)
{
foreach(Process procs in Process.GetProcesses(Environment.MachineName.ToStr ing()))
{
if(procs.MainModule.ModuleName.Equals(listBox1.Selec tedItem.ToString()))
{
procs.Kill();
break;
}
}
}


Ohh and Rauntec...man you know programming!

Just one curious question...by this--->if(process.MainWindowTitle.Length>0)<---do you mean on the number of letters in the main title of the window????lol.....
And here--->Process[] procs=Process.GetProcesses(".");<---why here you use (".") instead of the Environment.MachineName.ToString() ???
__________________
GOODBYE FOREVER EVERYONE...

Last edited by S.T.A.R.S.; June 10th, 2009 at 01:33..
S.T.A.R.S. is offline   Reply With Quote