C# - Get list of open tasks

前端 未结 4 770
耶瑟儿~
耶瑟儿~ 2020-12-15 10:45

I\'m trying to find a way to get the open tasks in C#. I\'ve been searching on google and can only find how to get a list of the processes. I want the onl

4条回答
  •  别那么骄傲
    2020-12-15 11:09

    I haven't tried it, but I suspect something like this:

    using System.Diagnostics;
    static void MyFunc()
    {
        Process[] processes = Process.GetProcesses();
        foreach(Process p in processes)
        {
           if (p.MainWindowHandle != 0)
           { // This is a GUI process
           }
           else
           { // this is a non-GUI / invisible process
           }
        }
    }
    

    The point is to check each process for a WindowHandle.

提交回复
热议问题