コード例 #1
0
 void UpdateProcList()
 {
     comboBox.Items.Clear();
     Process[] procs = Process.GetProcesses();
     ProcListItem item = new ProcListItem(GUITexts.get("Common"), -1);
     if (!comboBox.Items.Contains(item))
         comboBox.Items.Add(item);
     for (int i = 0; i < procs.Length; i++) {
         Process proc = procs[i];
         string str;
         try {
             str = string.Format("{0} ({1})", proc.ProcessName, proc.MainModule.FileVersionInfo.FileDescription);
         }
         catch {
             str = proc.ProcessName;
         }
         if (!comboBox.Items.Contains(new ProcListItem(str, proc.Id)))
             comboBox.Items.Add(new ProcListItem(str, proc.Id));
     }
     bool boo = false;
     try {
         int id;
         foreach (object obj in comboBox.Items){
             boo = false;
             id = ((ProcListItem)obj).id;
             foreach (Process proc in Process.GetProcesses()){
                 if ( id == proc.Id || id == -1)
                     boo = true;
             }
             if (!boo)
                 comboBox.Items.Remove(obj);
         }
     } catch (Exception) {}
 }
コード例 #2
0
 void UpdateTable(object sender, EventArgs e)
 {
     item_aktuell = (ProcListItem)comboBox.SelectedItem;
     if (item_aktuell == null)
         return;
     if (item_aktuell.id == -1) ShowPCTable();
     else {
         if (threadview != null)
             UpdateThreadView();
         threadview_button.Text = "ThreadView...";
         dataGridView.Rows.Clear();
         DataGridViewRow row;
         procs_cell = null;
         try {
             Process proc = Process.GetProcessById(item_aktuell.id);
             close_button.Text = GUITexts.get("Abort this process");
             copy_text = proc.ProcessName + "\\n";
             addRow(GUITexts.get("Process id"), proc.Id, "", true);
             try {
                 addRowS(GUITexts.get("Description"), proc.MainModule.FileVersionInfo.FileDescription,
                         GUITexts.get("Description of the main program"), true);
             } catch (Exception) { }
             try {
                 addRowS(GUITexts.get("Version"), proc.MainModule.FileVersionInfo.FileVersion,
                         GUITexts.get("Version of the main program"), true);
             } catch (Exception) { }
             try {
                 addRowS(GUITexts.get("Producer"), proc.MainModule.FileVersionInfo.CompanyName,
                         GUITexts.get("Producer of this program"), true);
             } catch (Exception) { }
             try {
                 addRowS(GUITexts.get("Comment"), proc.MainModule.FileVersionInfo.Comments,
                         GUITexts.get("Comment of the producer"), true);
             } catch (Exception) { }
             try {
                 if (proc.MainWindowTitle.Length > 2){
                     dataGridView.Rows.Add(new string[]{ proc.MainWindowTitle });
                     row = dataGridView.Rows[dataGridView.Rows.Count-1];
                     row.HeaderCell.Value = GUITexts.get("Title of the window");
                     windowtitle_cell.ToolTipText = GUITexts.get("Title of the main window");
                     windowtitle_cell = row.Cells[0];
                     windowtitle_cell.ReadOnly = true;
                 }
             }
             catch {
                 windowtitle_cell = null;
             }
             try {
                 addRow(GUITexts.get("Processpriority"), proc.PriorityClass.ToString());
             }
             catch (Exception) { }
             try {
                 dataGridView.Rows.Add(new string[]{ proc.Responding+"" });
                 row = dataGridView.Rows[dataGridView.Rows.Count-1];
                 row.HeaderCell.Value = GUITexts.get("Responding");
                 responsing_cell.ToolTipText = GUITexts.get("Says whether GUI of the process responds");
                 responsing_cell = row.Cells[0];
                 responsing_cell.ReadOnly = true;
             }
             catch {
                 responsing_cell = null;
                 dataGridView.Rows.RemoveAt(dataGridView.Rows.Count-1);
             }
             try {
                 dataGridView.Rows.Add(new string[]{ proc.MainWindowTitle });
                 row = dataGridView.Rows[dataGridView.Rows.Count-1];
                 row.HeaderCell.Value = "Abort";
                 exited_cell.ToolTipText = GUITexts.get("Says whether the process has been aborted");
                 exited_cell = row.Cells[0];
                 exited_cell.ReadOnly = true;
             }
             catch {
                 exited_cell = null;
                 dataGridView.Rows.RemoveAt(dataGridView.Rows.Count-1);
             }
             try {
                 dataGridView.Rows.Add(new string[]{ proc.Threads.Count+"" });
                 row = dataGridView.Rows[dataGridView.Rows.Count-1];
                 row.HeaderCell.Value = GUITexts.get("Number of threads");
                 threads_cell = row.Cells[0];
                 threads_cell.ReadOnly = true;
             }
             catch {
                 threads_cell = null;
                 if ((string)dataGridView.Rows[dataGridView.Rows.Count-1].HeaderCell.Value == GUITexts.get("Number of threads"))
                     dataGridView.Rows.RemoveAt(dataGridView.Rows.Count-1);
             }
             if (listener_thread != null){
                 listener_thread.Abort();
                 cpu_thread.Abort();
             }
             try {
                 listener = new ProcessListener(proc, taskmethods.max_ram, 1000);
                 string[] arr = { };
                 if (listener.werte_erwartbar()){
                     dataGridView.Rows.Add(arr);
                     row = dataGridView.Rows[dataGridView.Rows.Count-1];
                     row.HeaderCell.Value = GUITexts.get("CPU usage");
                     cpu_cell = row.Cells[0];
                     cpu_cell.ReadOnly = true;
                     dataGridView.Rows.Add(arr);
                     row = dataGridView.Rows[dataGridView.Rows.Count-1];
                     row.HeaderCell.Value = GUITexts.get("RAM usage");
                     ram_cell = row.Cells[0];
                     ram_cell.ReadOnly = true;
                     listener_thread = new Thread(listener.start);
                     listener_thread.Start();
                     cpu_thread = new Thread(cpuThread);
                     cpu_thread.Start();
                     dataGridView.Rows.Add(arr);
                     row = dataGridView.Rows[dataGridView.Rows.Count-1];
                     row.HeaderCell.Value = GUITexts.get("Used memory space");
                     gesram_cell = row.Cells[0];
                     gesram_cell.ReadOnly = true;
                     dataGridView.Rows.Add(arr);
                     row = dataGridView.Rows[dataGridView.Rows.Count-1];
                     row.HeaderCell.Value = GUITexts.get("UProcessortime");
                     row.HeaderCell.ToolTipText = GUITexts.get("UserProcessortime (hh:mm:ss)");
                     time_cell = row.Cells[0];
                     time_cell.ReadOnly = true;
                     dataGridView.Rows.Add(arr);
                     row = dataGridView.Rows[dataGridView.Rows.Count-1];
                     row.HeaderCell.Value = GUITexts.get("Processortime");
                     row.HeaderCell.ToolTipText = GUITexts.get("Total processortime");
                     totaltime_cell = row.Cells[0];
                     totaltime_cell.ReadOnly = true;
                 }
                 else {
                     cpu_cell = null;
                     ram_cell = null;
                 }
             }
             catch (Exception) { }
         }
         catch (Exception) { }
     }
 }
コード例 #3
0
 void ShowPCTable()
 {
     item_aktuell = new ProcListItem("", -1);
     threadview_button.Text = GUITexts.get("ServiceView...");
     comboBox.SelectedIndex = proc_list.IndexOf(GUITexts.get("Common"));
     copy_text = "\""+GUITexts.get("Common")+"\"\n";
     close_button.Text = GUITexts.get("Log out");
     dataGridView.Rows.Clear();
     exited_cell = null;
     threads_cell = null;
     windowtitle_cell = null;
     responsing_cell = null;
     DataGridViewRow row;
     try {
         try {
             addRow(GUITexts.get("Computer name"), Environment.MachineName);
             addRow(GUITexts.get("User name"), Environment.UserName);
             addRow(GUITexts.get("User domain name"), SystemInformation.UserDomainName);
             addRow(GUITexts.get("OS name"), compInfo.Info.OSFullName);
             addRow(GUITexts.get("OS platform"), compInfo.Info.OSPlatform);
             addRow(GUITexts.get("OS version"), compInfo.Info.OSVersion);
             addRow(GUITexts.get("Bootmode"), SystemInformation.BootMode.ToString());
             addRow(GUITexts.get("Ping"), "", "Type network address in", false);
             addRow(GUITexts.get("Number of monitors"), SystemInformation.MonitorCount);
             addRow(GUITexts.get("Size of the monitor"), string.Format(GUITexts.get("Height")+": {0}, "+GUITexts.get("Width")+": {1}",
                                                     SystemInformation.PrimaryMonitorSize.Height,
                                                     SystemInformation.PrimaryMonitorSize.Width),
                    GUITexts.get("Size of the primary monitor"), true);
             try {
                 string volume = "";
                 string label;
                 foreach(string str in Environment.GetLogicalDrives()){
                     label = compInfo.FileSystem.GetDriveInfo(str).VolumeLabel;
                     volume += str;
                     if (label != "")
                         volume += string.Format(" ({0})", label);
                     volume += "; ";
                 }
                 addRow(GUITexts.get("Volumes"), volume);
             }
             catch { }
         }
         catch (Exception) { }
         dataGridView.Rows.Add(new string[]{});
         row = dataGridView.Rows[dataGridView.Rows.Count-1];
         row.HeaderCell.Value = GUITexts.get("Number of processes");
         procs_cell = row.Cells[0];
         procs_cell.ReadOnly = true;
         dataGridView.Rows.Add(new string[]{});
         row = dataGridView.Rows[dataGridView.Rows.Count-1];
         row.HeaderCell.Value = GUITexts.get("CPU usage");
         cpu_cell = row.Cells[0];
         cpu_cell.ReadOnly = true;
         dataGridView.Rows.Add(new string[]{});
         row = dataGridView.Rows[dataGridView.Rows.Count-1];
         row.HeaderCell.Value = GUITexts.get("RAM usage");
         ram_cell = row.Cells[0];
         ram_cell.ReadOnly = true;
         cpu_thread = new Thread(cpuThread);
         cpu_thread.Start();
     }
     catch (Exception) { }
 }