开发者

Getting a list of processes in ASP.NET

As the title implies, is there any way I could do this?

I'm trying to do this in an .aspx, this is my current code:

    <script runat="server">
    //using System.Diagnostics;
    Process[] processes = Syst开发者_开发问答em.Diagnostics.Process.GetProcesses();


    foreach(Process process in processes)
    {
        lbl = process.MainWindowTitle;
    }
</script>

But it's saying foreach isn't a valid token.


Like everyone else said Process.GetProcesses()

If you use LinqPad you can run this in Statements mode to see how it works and play with it.

Process[] processes = Process.GetProcesses();
foreach(Process process in processes)
{
    Console.WriteLine(process.ProcessName);
}


If you are using .NET, you can call System.Diagnostics.Process.GetProcesses() to retrieve an array of Process objects.

Note that this methods has overloads, and that perhaps one of the overloads may be more suitable to your situation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜