/// <summary>
        /// 获取所有进程
        /// </summary>
        public ObservableCollection <RunningProcess> GetProcessNow()
        {
            bool judge;
            int  j;

            ObservableCollection <RunningProcess> processes = new ObservableCollection <RunningProcess>();
            var details = ProcessDiagnosticInfo.GetForProcesses().OrderByDescending(x => x.ExecutableFileName);

            foreach (var detail in details)
            {
                if (detail.Parent != null)
                {
                    if ((!detail.ExecutableFileName.Equals("winlogon.exe")) && (!detail.ExecutableFileName.Equals("System")) && (!detail.ExecutableFileName.Equals("svchost.exe")) && (!detail.Parent.ExecutableFileName.Equals("svchost.exe") && (!detail.Parent.ExecutableFileName.Equals("wininit.exe"))))
                    {
                        for (j = 0, judge = false; j < processes.Count; j++)
                        {
                            if (processes[j].id == detail.Parent.ProcessId)
                            {
                                judge = true;
                            }
                        }
                        if (judge == false)
                        {
                            var temp2 = new RunningProcess(detail.ExecutableFileName, detail.ProcessId, detail.Parent.ExecutableFileName, detail.Parent.ProcessId);
                            processes.Add(temp2);
                        }
                    }
                }
            }
            return(processes);
        }
Esempio n. 2
0
        private async void Page_LoadedAsync(object sender, RoutedEventArgs e)
        {
            foreach (var info in await AppDiagnosticInfo.RequestInfoAsync())
            {
                /*Items.Add(new AppInfo
                 * {
                 *  Id = info.AppInfo.Id,
                 *  PackageFamilyName = info.AppInfo.PackageFamilyName,
                 *  Description = info.AppInfo.DisplayInfo.Description,
                 *  DisplayName = info.AppInfo.DisplayInfo.DisplayName,
                 *  AppUserModelId = info.AppInfo.AppUserModelId,
                 * });*/
            }

            foreach (var info in ProcessDiagnosticInfo.GetForProcesses())
            {
                /*ProcessItems.Add(new ProcessInfo
                 * {
                 *  ExecutableFileName = info.ExecutableFileName,
                 *  ProcessId = $"{info.ProcessId}",
                 *  CpuUsage = $"{info.CpuUsage.GetReport().UserTime:hh':'mm':'ss}",
                 *  MemoryUsage = $"{info.MemoryUsage.GetReport().WorkingSetSizeInBytes:N0}",
                 * });*/
            }
        }
Esempio n. 3
0
        public void Update()
        {
            // We're clearing and recreating the process list each time, but the list is typically long (150-250 processes),
            // so we can't use the same add/remove/update technique we use for packaged apps, because it's too slow.
            Clear();

            IReadOnlyList <ProcessDiagnosticInfo> processes = ProcessDiagnosticInfo.GetForProcesses();

            if (processes != null)
            {
                foreach (ProcessDiagnosticInfo process in processes)
                {
                    BitmapImage image = null;
                    if (process.IsPackaged)
                    {
                        image = defaultAppImage;
                    }
                    else
                    {
                        image = defaultProcessImage;
                    }
                    ProcRowInfo processInfo = new ProcRowInfo(process, image);
                    Add(processInfo);
                }
            }
        }
        /// <summary>
        /// request for process info
        /// </summary>
        private void LoadProcesses()
        {
            mainViewModel.ProcessList.Clear();
            List <ProcessDiagnosticInfo> processList = ProcessDiagnosticInfo.GetForProcesses().ToList();

            processList.ForEach(o => mainViewModel.ProcessList.Add(new ProcessInfoModel(o)));
        }
 public AddProcess()
 {
     this.InitializeComponent();
     foreach (ProcessDiagnosticInfo ii in ProcessDiagnosticInfo.GetForProcesses())
     {
         procces.Items.Add(ii.ExecutableFileName);
     }
 }
        private int getMemoryPerformance()
        {
            IReadOnlyList <ProcessDiagnosticInfo> list = ProcessDiagnosticInfo.GetForProcesses();

            var  a = MemoryManager.GetProcessMemoryReport();
            long b = (long)a.TotalWorkingSetUsage;
            long c = (long)a.PrivateWorkingSetUsage;

            return((int)(c * 100 / b));
        }
    public static async Task <bool> CheckForRunningProcess(string processName)
    {
        //Requests permission for app.
        await AppDiagnosticInfo.RequestAccessAsync();

        //Gets the running processes.
        var processes = ProcessDiagnosticInfo.GetForProcesses();

        //Returns result of searching for process name.
        return(processes.Any(processDiagnosticInfo => processDiagnosticInfo.ExecutableFileName.Contains(processName)));
    }
Esempio n. 8
0
        public Temperature()
        {
            var a = ProcessDiagnosticInfo.GetForProcesses();

            foreach (var i in a)
            {
                string s = i.CpuUsage.GetReport().KernelTime.TotalMilliseconds.ToString();

                s += 1;
            }
        }
        private int getCpuPerformance()
        {
            IReadOnlyList <ProcessDiagnosticInfo> list = ProcessDiagnosticInfo.GetForProcesses();

            double sumUsage = 0, sumTotal = 0;

            foreach (var item in list)
            {
                sumUsage += item.CpuUsage.GetReport().UserTime.Milliseconds;
                sumTotal += item.CpuUsage.GetReport().UserTime.Milliseconds + item.CpuUsage.GetReport().KernelTime.Milliseconds;
            }

            sumTotal = (sumUsage * 100 / sumTotal);

            return((int)sumTotal);
        }
Esempio n. 10
0
        /// <summary>
        /// 获取所有进程(接口实现) : 包括Win32 与 UWP
        /// </summary>
        /// <returns>ObservableCollection<Process></returns>
        public ObservableCollection <Process> GetProcessNow()
        {
            ObservableCollection <Process> processes = new ObservableCollection <Process>();

            //取出所有进程
            IReadOnlyList <ProcessDiagnosticInfo> details = ProcessDiagnosticInfo.GetForProcesses();

            foreach (ProcessDiagnosticInfo detail in details)
            {
                if (detail.Parent != null)
                {
                    if ((!detail.ExecutableFileName.Equals("winlogon.exe")) && (!detail.ExecutableFileName.Equals("svchost.exe")) && (!detail.Parent.ExecutableFileName.Equals("wininit.exe")))
                    {
                        var temp2 = new Process(detail.ExecutableFileName, "2333", 3);
                        processes.Add(temp2);
                    }
                }
            }
            return(processes);
        }
Esempio n. 11
0
        public MainPage()
        {
            this.InitializeComponent();

            IReadOnlyList <ProcessDiagnosticInfo> processes = ProcessDiagnosticInfo.GetForProcesses();

            if (processes != null)
            {
                foreach (ProcessDiagnosticInfo process in processes)
                {
                    string exeName = process.ExecutableFileName;
                    string pid     = process.ProcessId.ToString();

                    systemProcesses.Add(new Process {
                        Name = exeName, ProcessID = pid
                    });
                    Debug.WriteLine(exeName + " " + pid);
                }
            }
        }
Esempio n. 12
0
        private async void Timer_Tick(object sender, object e)
        {
            Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
            try
            {
                var s = "";
                Windows.Storage.StorageFile sampleFile = await storageFolder.GetFileAsync("procs.txt");

                list.Items.Clear();
                foreach (var i in (await Windows.Storage.FileIO.ReadTextAsync(sampleFile)).Split('\n'))
                {
                    if (i.IndexOf('~') != -1)
                    {
                        if (i.Split('~')[0] == "default" && s == "")
                        {
                            s = i.Split('~')[1];
                        }
                        else
                        {
                            foreach (ProcessDiagnosticInfo ii in ProcessDiagnosticInfo.GetForProcesses())
                            {
                                if (i.Split('~')[0] == ii.ExecutableFileName)
                                {
                                    s = i.Split('~')[1];
                                }
                            }
                        }
                        Grid g = new Grid()
                        {
                            HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch
                        };
                        ListViewItem lvi = new ListViewItem()
                        {
                            Content = g, HorizontalAlignment = HorizontalAlignment.Stretch, HorizontalContentAlignment = HorizontalAlignment.Stretch
                        };
                        g.Children.Add(new TextBlock()
                        {
                            Text = i.Split('~')[0], HorizontalAlignment = HorizontalAlignment.Left
                        });
                        g.Children.Add(new TextBlock()
                        {
                            Text = i.Split('~')[1], HorizontalAlignment = HorizontalAlignment.Right
                        });
                        list.Items.Add(lvi);
                    }
                }
                if (s != singlton.status)
                {
                    singlton.status = s;
                }
                answTextBlock.Text = s;
                //await Windows.Storage.FileIO.WriteTextAsync(sampleFile, "Test~System\nexplorer.exe~играет в проводник windows");
            }
            catch (FileNotFoundException ex)
            {
                Windows.Storage.StorageFile sampleFile = await storageFolder.CreateFileAsync("procs.txt", Windows.Storage.CreationCollisionOption.ReplaceExisting);

                answTextBlock.Text = ex.Message;
                await Windows.Storage.FileIO.WriteTextAsync(sampleFile, "default~ ");
            }
            catch (Exception ex)
            {
                answTextBlock.Text = ex.Message;
            }
        }