|
||||||
| C# Programming C# (pronounced C-sharp) is a new object oriented language from Microsoft and is derived from C and C++. It also borrows a lot of concepts from Java too including garbage collection. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
im currently using this code..
using System.Diagnostics; foreach (Process p in Process.GetProcesses()) { if (p.ProcessName.ToLower() == "star") if (p.ProcessName.ToLower() == "firefox") p.Kill(); } } star and firefox are just examples of the .exe(s) running.. it doesn't quite work when I add another line of "if (p.ProcessName..etc) also with the firefox line, how can I check for a specific website opened with firefox? ex.. "firefox", "www.google.com" ? thanks ahead of time. |
| Sponsored Links |
|
|
|
|||
|
thanks for the explanation, i understand what i did wrong now. however the code that you gave me doesn't seem to work, i get compile errors.
Code:
private void button1_Click(object sender, EventArgs e)
{
switch (p.ProcessName.ToLower())
{
case "firefox": {}
case "star": {}
{
p.Kill;
break;
}
}
}
|
|
|||||
|
I would use your old code but just use an or in your if statement.
Code:
foreach (Process p in Process.GetProcesses())
{
if (p.ProcessName.ToLower() == "star" || p.ProcessName.ToLower() == "firefox")
p.Kill();
}
|
|
|||||
|
You still need to define p as a Process. I meant just replace the If bit with my code.
|
|
|||||
|
If you can get the title of the process (one of p's properties, I suppose), then it usually says the name of the site in the address bar. If not, I'm sure there's an API you could automate.
|
|
|||||
|
I couldn't be sure. You know when you type "p" and then type a dot? It shows you a list of members. Take a look for a name one.
|
| Sponsored Links |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Process List | wazofski | Visual Basic Programming | 4 | 06-24-2008 01:55 PM |
| nice affetcts only pthread or process as a whole? (Linux) | mynickmynick | C and C++ | 0 | 05-07-2008 12:24 PM |
| Make a Process undetectable? | TcM | Software Development Tools | 14 | 12-30-2006 04:24 PM |
| Chinese kill 50,000 dogs | Void | The Lounge | 12 | 08-17-2006 03:57 PM |
| Design Process | Dan | Website Design | 3 | 07-13-2006 12:11 PM |
| Xav | ........ | 1357.94 |
| MeTh0Dz|Reb0rn | ........ | 1077.71 |
| WingedPanther | ........ | 919.18 |
| marwex89 | ........ | 906.86 |
| morefood2001 | ........ | 900.18 |
| John | ........ | 890.77 |
| Brandon W | ........ | 770.65 |
| chili5 | ........ | 312.39 |
| Steve.L | ........ | 264.99 |
| dcs | ........ | 232.34 |
Goal: 100,000 Posts
Complete: 83%