Exemple #1
0
 private void ProcessCreated(ProcessInfo process)
 {
     _table[process.ProcessId] = process;
     ExcludeOldDeleted();
 }
Exemple #2
0
        private bool TryConvert(ManagementBaseObject obj, out ProcessInfo process)
        {
            process           = new ProcessInfo();
            process.IsDefault = true;

            if (obj == null || (uint?)obj["ProcessId"] == 0)
            {
                return(false);
            }

            process.Caption           = (string)obj["Caption"];
            process.CommandLine       = (string)obj["CommandLine"];
            process.CreationClassName = (string)obj["CreationClassName"];

            if (obj["CreationDate"] != null)
            {
                process.CreationDate = ManagementDateTimeConverter.ToDateTime((string)obj["CreationDate"]);
            }

            process.CSCreationClassName = (string)obj["CSCreationClassName"];
            process.CSName         = (string)obj["CSName"];
            process.Description    = (string)obj["Description"];
            process.ExecutablePath = (string)obj["ExecutablePath"];
            process.ExecutionState = (ushort?)obj["ExecutionState"];
            process.Handle         = (string)obj["Handle"];
            process.HandleCount    = (uint?)obj["HandleCount"];

            if (obj["InstallDate"] != null)
            {
                process.InstallDate = ManagementDateTimeConverter.ToDateTime((string)obj["InstallDate"]);
            }

            process.KernelModeTime        = (ulong?)obj["KernelModeTime"];
            process.MaximumWorkingSetSize = (uint?)obj["MaximumWorkingSetSize"];
            process.MinimumWorkingSetSize = (uint?)obj["MinimumWorkingSetSize"];
            process.Name = (string)obj["Name"];
            process.OSCreationClassName = (string)obj["OSCreationClassName"];
            process.OSName = (string)obj["OSName"];
            process.OtherOperationCount        = (ulong?)obj["OtherOperationCount"];
            process.OtherTransferCount         = (ulong?)obj["OtherTransferCount"];
            process.PageFaults                 = (uint?)obj["PageFaults"];
            process.PageFileUsage              = (uint?)obj["PageFileUsage"];
            process.ParentProcessId            = (uint?)obj["ParentProcessId"];
            process.PeakPageFileUsage          = (uint?)obj["PeakPageFileUsage"];
            process.PeakVirtualSize            = (ulong?)obj["PeakVirtualSize"];
            process.PeakWorkingSetSize         = (uint?)obj["PeakWorkingSetSize"];
            process.Priority                   = (uint?)obj["Priority"];
            process.PrivatePageCount           = (ulong?)obj["PrivatePageCount"];
            process.ProcessId                  = (uint)obj["ProcessId"];
            process.QuotaNonPagedPoolUsage     = (uint?)obj["QuotaNonPagedPoolUsage"];
            process.QuotaPagedPoolUsage        = (uint?)obj["QuotaPagedPoolUsage"];
            process.QuotaPeakNonPagedPoolUsage = (uint?)obj["QuotaPeakNonPagedPoolUsage"];
            process.QuotaPeakPagedPoolUsage    = (uint?)obj["QuotaPeakPagedPoolUsage"];
            process.ReadOperationCount         = (ulong?)obj["ReadOperationCount"];
            process.ReadTransferCount          = (ulong?)obj["ReadTransferCount"];
            process.SessionId                  = (uint?)obj["SessionId"];
            process.Status = (string)obj["Status"];

            if (obj["TerminationDate"] != null)
            {
                process.TerminationDate = ManagementDateTimeConverter.ToDateTime((string)obj["TerminationDate"]);
            }
            process.ThreadCount         = (uint?)obj["ThreadCount"];
            process.UserModeTime        = (ulong?)obj["UserModeTime"];
            process.VirtualSize         = (ulong?)obj["VirtualSize"];
            process.WindowsVersion      = (string)obj["WindowsVersion"];
            process.WorkingSetSize      = (ulong?)obj["WorkingSetSize"];
            process.WriteOperationCount = (ulong?)obj["WriteOperationCount"];
            process.WriteTransferCount  = (ulong?)obj["WriteTransferCount"];

            process.IsDefault = false;
            return(true);
        }