示例#1
0
        static void Main(string[] args)
        {
            var processes = SystemInformation.EnumProcessesExtended();

            foreach (var pi in processes)
            {
                Console.Write($"{pi.ImageName} ({pi.ProcessId}) Threads: {pi.Threads} Parent: {pi.ParentProcessId} Virtual Size: {pi.VirtualSize}");
                if (pi.ProcessId > 0)
                {
                    using (var process = NativeProcess.TryOpen(ProcessAccessMask.QueryLimitedInformation, pi.ProcessId)) {
                        if (process != null)
                        {
                            Console.Write($" Start: {process.CreateTime} Managed: {process.IsManaged} In Job: {process.IsInAnyJob} Protection: {process.Protection}");
                        }
                    }
                }
                Console.WriteLine();
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            var info = SystemInformation.EnumProcessesExtended();

            Console.WriteLine($"Total Processes {info.Count}");

            foreach (var process in info)
            {
                Console.WriteLine($"PID: {process.ProcessId} Parent: {process.ParentProcessId} Threads: {process.ThreadCount} Image: {process.ImageName}"
                                  + $" Base Pri: {process.BasePriority} Created: {process.CreateTime.ToLocalTime()} Kernel: {process.KernelTime} User: {process.UserTime}");

                if (process.Threads != null)
                {
                    foreach (var thread in process.Threads)
                    {
                        Console.WriteLine($"  Id: {thread.ThreadId} Created: {thread.CreateTime.ToLocalTime()} Pri: {thread.Priority} BasePri: {thread.BasePriority} "
                                          + $"User: {thread.UserTime} Kernel: {thread.KernelTime} CtxSwitch: {thread.ContextSwitches} Address: {thread.StartAddress} State: {thread.State}"
                                          + $" Wait Reason: {thread.WaitReason} Wait time: {thread.WaitTime}");
                    }
                }
            }
        }