コード例 #1
0
 public CoherentMonitor()
 {
     queue       = new Queue <QueueItem>();
     accounts    = new Dictionary <ushort, AccountProcessInfo>();
     processes   = new Dictionary <int, ProcessInfo>();
     processInfo = new Windows.ProcessInfo();
 }
コード例 #2
0
            private int GetChildProcess(int pid)
            {
                if (canReadMemory)
                {
                    var noChild   = true;
                    var processes = Process.GetProcesses();
                    var cid       = 0;

                    using (var pi = new Windows.ProcessInfo())
                    {
                        foreach (var p in processes)
                        {
                            using (p)
                            {
                                if (noChild)
                                {
                                    try
                                    {
                                        if (pi.Open(p.Id))
                                        {
                                            if (pi.GetParent() == pid)
                                            {
                                                noChild = false;
                                                cid     = p.Id;
                                            }
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                        Util.Logging.Log(e);
                                    }
                                }
                            }
                        }
                    }

                    return(cid);
                }

                using (var searcher = new ManagementObjectSearcher("SELECT ProcessId FROM Win32_Process WHERE ParentProcessID=" + pid))
                {
                    using (var results = searcher.Get())
                    {
                        foreach (ManagementObject o in results)
                        {
                            return((int)(uint)o["ProcessId"]);
                        }
                    }
                }

                return(0);
            }