} //Converte byte para o valor correspondente(KB, MB, GB...) e torna tal valor em double. #endregion private void frmmain_Load(object sender, EventArgs e) { Services.Load(); #region PERFORMANCE DATA ramCounter = new PerformanceCounter("Memory", "Available MBytes"); int procCount = System.Environment.ProcessorCount; for (int i = 0; i < procCount; i++) { System.Diagnostics.PerformanceCounter pc = new System.Diagnostics.PerformanceCounter("Processor", "% Processor Time", i.ToString()); cpuCounters.Add(pc); } timer_performance.Enabled = true; #endregion #region General Information //Tab 1 - General Informations, informações gerais sobre o Windows vinculado ao Hardware foreach (ManagementObject seacher in Catcher.Get()) { foreach (ManagementObject seacher2 in CatcherHD.Get()) { foreach (PropertyData data in seacher2.Properties) { if (seacher2["DriveType"].ToString() == "3") { if (data.Name == "Size") { size += Convert.ToUInt64(data.Value); } if (data.Name == "FreeSpace") { freespace += Convert.ToUInt64(data.Value); } } } } listgeneral.Groups.Add("Sitema", "Sitema"); ShowGeneralWin32(OSVersionInfo.GetOSVersionInfo().FullName, "Windows Edition", listgeneral.Groups[0]); ShowGeneralWin32("Name", seacher, "Processador: ", listgeneral.Groups[0]); ShowGeneralVisualBasic(); ShowGeneralWin32("SystemName", seacher, "Nome do computador", listgeneral.Groups[0]); listgeneral.Groups.Add("Sitema", "Placa mãe"); ShowGeneralWin32(GetBoardMaker(), "Fornecedor", listgeneral.Groups[1]); ShowGeneralWin32(GetBoardProductId(), "Modelo", listgeneral.Groups[1]); listgeneral.Groups.Add("Sitema", "Hard Disk"); ShowGeneralWin32(ToFileSize(freespace), "HD Free Space", listgeneral.Groups[2]); ShowGeneralWin32(ToFileSize(size), "HD Total Space", listgeneral.Groups[2]); progressBar1.Maximum = 100; int percent = Convert.ToInt32(100 - ((freespace * 100) / size)); progressBar1.Value = percent; label11.Text = percent + "%"; #endregion #region Processor //Tab 3 - Processor Informations foreach (PropertyData data in seacher.Properties) { if (data.Value != null && data.ToString() != "") { item = new ListViewItem(); item.Text = data.Name; item.SubItems.Add(data.Value.ToString()); listProcessor.Items.Add(item); } } } #endregion #region Cache //Tab 3 - Cache foreach (ManagementObject seacher3 in Cache.Get()) { ShowCacheMemory("Purpose", seacher3, "Purpose"); ShowCacheMemory("CacheSpeed", seacher3, "CacheSpeed"); ShowCacheMemory("BlockSize", seacher3, "BlockSize"); ShowCacheMemory("DeviceID", seacher3, "DeviceID"); ShowCacheMemory("InstalledSize", seacher3, "InstalledSize"); ShowCacheMemory("MaxCacheSize", seacher3, "MaxCacheSize"); ShowCacheMemory("NumberOfBlocks", seacher3, "NumberOfBlocks"); } #endregion #region HD //Tab 4 - Disk Informations foreach (ManagementObject seacher2 in CatcherHD.Get()) { foreach (PropertyData data in seacher2.Properties) { if (data.Value != null && data.ToString() != "") { ListViewItem i = new ListViewItem(); i.Text = data.Name; try { if (data.Name != "StartingOffset" && data.Name != "NumberOfBlocks") // Informações referentes ao espaço são coletadas e ajustadas { ulong value = Convert.ToUInt64(data.Value); if (value >= 100000) { i.SubItems.Add(ToFileSize(value)); } else { i.SubItems.Add(data.Value.ToString()); } } else { i.SubItems.Add(data.Value.ToString()); } } catch { i.SubItems.Add(data.Value.ToString()); } listHD.Items.Add(i); } } } #endregion #region Processes listProcessosRunning.Columns.Add("name", "Nome", 120); listProcessosRunning.Columns.Add("ID", "ID", 80); listProcessosRunning.Columns.Add("Threads", "Threads", 100); listProcessosRunning.Columns.Add("R", "RAM", 90); listProcessosRunning.Columns.Add("R", "CPU", 80); Process[] proc = Process.GetProcesses(); foreach (Process pro in proc) { PerformanceCounter counter = new PerformanceCounter("Process", "% Processor Time", pro.ProcessName); PerformanceCounter counterRAM = new PerformanceCounter("Process", "Working Set - Private", pro.ProcessName); counter.NextValue(); int cpuUseage = (int)counter.NextValue(); ListViewItem it = new ListViewItem(); it.Text = pro.ProcessName; it.SubItems.Add(pro.Id.ToString()); it.SubItems.Add(pro.Threads.Count.ToString()); it.SubItems.Add((((double)counterRAM.NextValue() / 1024) / 1000) + " MB"); it.SubItems.Add(cpuUseage + "%"); listProcessosRunning.Items.Add(it); } #endregion #region SpecificPrograms Process[] pro_gt = Process.GetProcessesByName("Taskmgr"); #region OFFICE Process[] pro_moW = Process.GetProcessesByName("WINWORD"); ForeachSpecificAdd(pro_moW); Process[] pro_moE = Process.GetProcessesByName("EXCEL"); ForeachSpecificAdd(pro_moE); Process[] pro_moA = Process.GetProcessesByName("MSACCESS"); ForeachSpecificAdd(pro_moA); Process[] pro_moOne = Process.GetProcessesByName("ONENOTE"); ForeachSpecificAdd(pro_moOne); Process[] pro_moOUT = Process.GetProcessesByName("OUTLOOK"); ForeachSpecificAdd(pro_moOUT); Process[] pro_moOneTEM = Process.GetProcessesByName("ONENOTEM"); ForeachSpecificAdd(pro_moOneTEM); Process[] pro_moPOWER = Process.GetProcessesByName("POWERPNT"); ForeachSpecificAdd(pro_moPOWER); Process[] pro_moPUB = Process.GetProcessesByName("MSPUB"); ForeachSpecificAdd(pro_moPUB); #endregion Process[] pro_libof = Process.GetProcessesByName("LibreOffice"); ForeachSpecificAdd(pro_libof); Process[] pro_vs = Process.GetProcessesByName("devenv"); ForeachSpecificAdd(pro_vs); Process[] pro_IE = Process.GetProcessesByName("iexplore"); ForeachSpecificAdd(pro_IE); Process[] pr_gooc = Process.GetProcessesByName("chrome"); ForeachSpecificAdd(pr_gooc); #region EDGE Process[] proc_ME = Process.GetProcessesByName("MicrosoftEdge"); ForeachSpecificAdd(proc_ME); Process[] proc_MECP = Process.GetProcessesByName("MicrosoftEdgeCP"); ForeachSpecificAdd(proc_MECP); #endregion Process[] pro_fire = Process.GetProcessesByName("Firefox"); ForeachSpecificAdd(pro_fire); Process[] pro_we = Process.GetProcessesByName("explorer"); ForeachSpecificAdd(pro_we); #endregion #region Services listservices.Columns.Add("Nome", 150); listservices.Columns.Add("Nome de exibição", 150); listservices.Columns.Add("Status", 90); listservices.Columns.Add("Descrição", 90); foreach (ServiceDados service in Services.AllServices) { item = new ListViewItem(); item.Text = service.Nome; item.SubItems.Add(service.Display_nome); item.SubItems.Add(service.Status); item.SubItems.Add(service.Descrição); listservices.Items.Add(item); } #endregion }
} //Converte byte para o valor correspondente(KB, MB, GB...) e torna tal valor em double. #endregion private void frmmain_Load(object sender, EventArgs e) { #region PERFORMANCE DATA ramCounter = new PerformanceCounter("Memory", "Available MBytes"); int procCount = System.Environment.ProcessorCount; for (int i = 0; i < procCount; i++) { System.Diagnostics.PerformanceCounter pc = new System.Diagnostics.PerformanceCounter("Processor", "% Processor Time", i.ToString()); cpuCounters.Add(pc); } timer_performance.Enabled = true; #endregion #region General Information //Tab 1 - General Informations, informações gerais sobre o Windows vinculado ao Hardware foreach (ManagementObject seacher in Catcher.Get()) { foreach (ManagementObject seacher2 in CatcherHD.Get()) { foreach (PropertyData data in seacher2.Properties) { if (seacher2["DriveType"].ToString() == "3") { if (data.Name == "Size") { size += Convert.ToUInt64(data.Value); } if (data.Name == "FreeSpace") { freespace += Convert.ToUInt64(data.Value); } } } } ShowGeneralWin32(OSVersionInfo.GetOSVersionInfo().FullName, "Windows Edition"); ShowGeneralWin32("Name", seacher, "Processador: "); ShowGeneralVisualBasic(); ShowGeneralWin32("SystemName", seacher, "Nome do computador"); ShowGeneralWin32(ToFileSize(freespace), "HD Free Space"); ShowGeneralWin32(ToFileSize(size), "HD Total Space"); progressBar1.Maximum = 100; int percent = Convert.ToInt32(100 - ((freespace * 100) / size)); progressBar1.Value = percent; label11.Text = percent + "%"; #endregion #region Processor //Tab 3 - Processor Informations foreach (PropertyData data in seacher.Properties) { if (data.Value != null && data.ToString() != "") { ListViewItem i = new ListViewItem(); i.Text = data.Name; i.SubItems.Add(data.Value.ToString()); listProcessor.Items.Add(i); } } } #endregion #region Cache //Tab 3 - Cache foreach (ManagementObject seacher3 in Cache.Get()) { ShowCacheMemory("Purpose", seacher3, "Purpose"); ShowCacheMemory("CacheSpeed", seacher3, "CacheSpeed"); ShowCacheMemory("BlockSize", seacher3, "BlockSize"); ShowCacheMemory("DeviceID", seacher3, "DeviceID"); ShowCacheMemory("InstalledSize", seacher3, "InstalledSize"); ShowCacheMemory("MaxCacheSize", seacher3, "MaxCacheSize"); ShowCacheMemory("NumberOfBlocks", seacher3, "NumberOfBlocks"); } #endregion #region HD //Tab 4 - Disk Informations foreach (ManagementObject seacher2 in CatcherHD.Get()) { foreach (PropertyData data in seacher2.Properties) { if (data.Value != null && data.ToString() != "") { ListViewItem i = new ListViewItem(); i.Text = data.Name; try { if (data.Name != "StartingOffset" && data.Name != "NumberOfBlocks") // Informações referentes ao espaço são coletadas e ajustadas { ulong value = Convert.ToUInt64(data.Value); if (value >= 100000) { i.SubItems.Add(ToFileSize(value)); } else { i.SubItems.Add(data.Value.ToString()); } } else { i.SubItems.Add(data.Value.ToString()); } } catch { i.SubItems.Add(data.Value.ToString()); } listHD.Items.Add(i); } } } #endregion #region Processes listProcessosRunning.Columns.Add("ID", "ID", 150); listProcessosRunning.Columns.Add("Threads", "Threads", 150); listProcessosRunning.Columns.Add("TPT", "TPT", 150); listProcessosRunning.Columns.Add("UPT", "UPT", 150); listProcessosRunning.Columns.Add("MV", "Memória virtual", 150); listProcessosRunning.Columns.Add("R", "RAM", 150); Process[] proc = Process.GetProcesses(); foreach (Process pro in proc) { try { ListViewItem item = new ListViewItem(); item.Text = pro.Id.ToString(); item.SubItems.Add(pro.ProcessName); item.SubItems.Add(pro.Threads.ToString()); item.SubItems.Add(pro.TotalProcessorTime.ToString()); item.SubItems.Add(pro.UserProcessorTime.ToString()); item.SubItems.Add(pro.VirtualMemorySize64.ToString()); item.SubItems.Add(pro.WorkingSet64.ToString()); listProcessosRunning.Items.Add(item); } catch { listProcessosRunning.Columns.RemoveByKey("TPT"); listProcessosRunning.Columns.RemoveByKey("UPT"); ListViewItem item = new ListViewItem(); item.Text = pro.Id.ToString(); item.SubItems.Add(pro.ProcessName); item.SubItems.Add(pro.Threads.ToString()); item.SubItems.Add(pro.VirtualMemorySize64.ToString()); item.SubItems.Add(pro.WorkingSet64.ToString()); listProcessosRunning.Items.Add(item); } } #endregion }