Process.GetProcesses()
-
Process[] procList = Process.GetProcesses();
It seems VS 2005 (maybe 2003 too) is buggy related to this code. If I have opened windows already before I start my application , VS only show 1 of them. But if I activate a window, which isn't listet in the process array, VS finds it immediately. Anybody here with the same experience? Is "EnumWindows" from Win32 API the only solution? -
Process[] procList = Process.GetProcesses();
It seems VS 2005 (maybe 2003 too) is buggy related to this code. If I have opened windows already before I start my application , VS only show 1 of them. But if I activate a window, which isn't listet in the process array, VS finds it immediately. Anybody here with the same experience? Is "EnumWindows" from Win32 API the only solution? -
Are you running this from inside the debugger or from within your own application?
You know you're a Land Rover owner when the best route from point A to point B is through the mud. Ed
-
What is
Process
, your variable or a framework class? (Sorry don't have access to my development machine).
You know you're a Land Rover owner when the best route from point A to point B is through the mud. Ed
-
Using the following code (.NET 2.0):
foreach (Process proc in System.Diagnostics.Process.GetProcesses())
{
Console.WriteLine(proc.ProcessName);
}Creates the following output:
aswUpdSv
spoolsv
CSRSS
WINLOGON
MaxBackServiceInt
Apache
CTFMON
firefox
explorer
vsmon
inetinfo
htpatch
ApacheMonitor
rundll32
SMSS
LSASS
mstask
WinPatrol
svchost
SyncServices
SERVICES
acrotray
svchost
ashDisp
Apache
zlclient
Amoumain
SciTE
mdm
TSVNCache
WinMgmt
ashServ
css
System
stisvc
SharpDevelop
IdleSo I'm not sure what yours is doing. (I tried this with C# Script, article here by me). And also created a simple executable and both seemed to run fine. I havn't tried it from within VS (I don't have the full edition, only the Express, but I will try it when I get the chance).
You know you're a Land Rover owner when the best route from point A to point B is through the mud. Ed
-
Using the following code (.NET 2.0):
foreach (Process proc in System.Diagnostics.Process.GetProcesses())
{
Console.WriteLine(proc.ProcessName);
}Creates the following output:
aswUpdSv
spoolsv
CSRSS
WINLOGON
MaxBackServiceInt
Apache
CTFMON
firefox
explorer
vsmon
inetinfo
htpatch
ApacheMonitor
rundll32
SMSS
LSASS
mstask
WinPatrol
svchost
SyncServices
SERVICES
acrotray
svchost
ashDisp
Apache
zlclient
Amoumain
SciTE
mdm
TSVNCache
WinMgmt
ashServ
css
System
stisvc
SharpDevelop
IdleSo I'm not sure what yours is doing. (I tried this with C# Script, article here by me). And also created a simple executable and both seemed to run fine. I havn't tried it from within VS (I don't have the full edition, only the Express, but I will try it when I get the chance).
You know you're a Land Rover owner when the best route from point A to point B is through the mud. Ed
Hello, sorry for my late answer. No, this code show only a single process. Try to open 2 or more SharpDevelop Instances and you'll see that you only get one of them. In the meantime I found a solution. First get the ThreadID with the Win32 API and then get the ProcessByID, this works.
-
Hello, sorry for my late answer. No, this code show only a single process. Try to open 2 or more SharpDevelop Instances and you'll see that you only get one of them. In the meantime I found a solution. First get the ThreadID with the Win32 API and then get the ProcessByID, this works.
Seraphin wrote:
Try to open 2 or more SharpDevelop Instances and you'll see that you only get one of them.
Nope I get all processes running as listed in the TaskManager :confused:
Seraphin wrote:
First get the ThreadID with the Win32 API and then get the ProcessByID, this works.
Seems a long way around. Try putting the following code:
using System;
using System.Diagnostics;class ListProcesses
{
static void Main(string[] args)
{
foreach (Process proc in Process.GetProcesses())
{
Console.WriteLine(proc.ProcessName);
}
Console.Write("Press ENTER to continue...");
Console.ReadLine();
}
}Into a text file, name it something (like listprocesses.cs) then run
csc listprocesses.cs
to compile it and then runlistprocesses.exe
. I just had a thought, are you running in a doman because maybe there's some security restriction in place which stops programs accessing other programs. Just a possibility?
You know you're a Land Rover owner when the best route from point A to point B is through the mud. Ed