Advertisement
BrandonSpendlove

Basic System Gather Application

Nov 6th, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 21.17 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Diagnostics;
  11. using System.Threading;
  12. using System.Management;
  13.  
  14. namespace ComputerInformation
  15. {
  16.     public partial class Form1 : Form
  17.     {
  18.  
  19.         ManagementObjectSearcher mos =
  20.         new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_Processor");
  21.  
  22.         ManagementObjectSearcher gpu =
  23.         new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_VideoController");
  24.  
  25.         ManagementObjectSearcher bios =
  26.         new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_BIOS");
  27.  
  28.         ManagementObjectSearcher fan =
  29.         new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_Fan");
  30.  
  31.         ManagementObjectSearcher ram =
  32.         new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_PhysicalMemory");
  33.  
  34.         ManagementObjectSearcher sound =
  35.         new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_SoundDevice");
  36.  
  37.         public static string cpuName;
  38.         public static bool cmdCpuName;
  39.         public static string gpuRamS;
  40.         public static int gpuRam;
  41.         public static string gpuRamF;
  42.  
  43.         public Form1()
  44.         {
  45.             InitializeComponent();
  46.  
  47.                 foreach (ManagementObject mo in mos.Get())
  48.                 {
  49.                     #region ApplicationInformationText for CPU
  50.                     richTextBox1.AppendText(string.Format("{0}", (string)(mo["Name"])));
  51.                     richTextBox2.AppendText(string.Format("{0}", (ushort)(mo["Architecture"])));
  52.                     richTextBox3.AppendText(string.Format("{0}", mo["NumberOfCores"]).ToString());
  53.                     richTextBox4.AppendText(string.Format("{0}", (string)(mo["ProcessorId"])));
  54.                     richTextBox5.AppendText(string.Format("{0}", mo["Manufacturer"]).ToString());
  55.                     richTextBox6.AppendText(string.Format("{0}", mo["SocketDesignation"]).ToString());
  56.                     richTextBox7.AppendText(string.Format("{0}", mo["SystemName"]).ToString());
  57.                     #endregion
  58.                 }
  59.                 foreach (ManagementObject mo in gpu.Get())
  60.                 {
  61.                     #region ApplicationInformationText for GPU
  62.                     richTextBox10.AppendText(string.Format("{0}", (string)(mo["Name"])));
  63.                     richTextBox11.AppendText(string.Format("{0}", mo["CurrentRefreshRate"]).ToString());
  64.                     richTextBox12.AppendText(string.Format("{0}", mo["CurrentHorizontalResolution"]).ToString());
  65.                     richTextBox13.AppendText(string.Format("{0}", mo["CurrentVerticalResolution"]).ToString());
  66.                     richTextBox14.AppendText(string.Format("{0}", (string)(mo["DriverVersion"])));
  67.                     richTextBox15.AppendText(string.Format("{0}", mo["MaxRefreshRate"]).ToString());
  68.                     #endregion
  69.                 }
  70.                 foreach (ManagementObject mo in bios.Get())
  71.                 {
  72.                     #region ApplicationInformationText for BIOS
  73.                     #endregion
  74.                 }
  75.         }
  76.  
  77.         private void Form1_Load(object sender, EventArgs e)
  78.         {
  79.  
  80.         }
  81.  
  82.         private void textBox1_TextChanged(object sender, EventArgs e)
  83.         {
  84.         }
  85.  
  86.         private void richTextBox1_TextChanged(object sender, EventArgs e)
  87.         {
  88.         }
  89.  
  90.         private void textBox1_TextChanged_1(object sender, EventArgs e)
  91.         {
  92.  
  93.         }
  94.  
  95.         //Arc...
  96.         private void button1_Click(object sender, EventArgs e)
  97.         {
  98.             MessageBox.Show("0 = x86 Platform" + "\n" + "1 = MIPS" + "\n" + "5 = ARM" + "\n" + "9 = x64 Platform", "Architecture Code Debug");
  99.         }
  100.  
  101.         //Cores
  102.         private void button2_Click(object sender, EventArgs e)
  103.         {
  104.             MessageBox.Show("Most likely this is the case:" + "\n" + "2 Cores = Dual Core CPU" + "\n" + "4 Cores = Quad Core CPU" + "\n" + "6 Cores = Hex CPU", "Information for Cores");
  105.         }
  106.  
  107.         //Company
  108.         private void button3_Click(object sender, EventArgs e)
  109.         {
  110.             MessageBox.Show("Company Names can be:" + "\n" + "GenuineIntel = Intel" + "\n" + "AMD = AMD", "Company CPU Name");
  111.         }
  112.  
  113.         private void richTextBox3_TextChanged(object sender, EventArgs e)
  114.         {
  115.  
  116.         }
  117.  
  118.         // Socket Des
  119.         private void button4_Click(object sender, EventArgs e)
  120.         {
  121.             MessageBox.Show("Sockets:" + "\n" + "0 = 1 CPU" + "\n" + "1 = 2 CPU's", "Socket Designation");
  122.         }
  123.  
  124.         //Information box for displaying from commands wrote into the console below...
  125.         private void richTextBox9_TextChanged(object sender, EventArgs e)
  126.         {
  127.  
  128.         }
  129.  
  130.         //Console for advance information on computer information...
  131.         private void richTextBox8_TextChanged(object sender, EventArgs e)
  132.         {
  133.             //Custom Commands in my Console...
  134.  
  135.             #region List of Commands if you write cmds
  136.             if (richTextBox8.Text == "cmds")
  137.             {
  138.                 richTextBox8.Clear();
  139.                 richTextBox9.Clear();
  140.                 richTextBox9.AppendText("Commands for the Console:"
  141.                 + "\n"
  142.                 + "\n"
  143.                 + "biosinfo, cpucores, cpuname, cputype, faninfo, gpudriver, gpuname, gpurefresh, family, logicalcores, raminfo, resolution, soundinfo, sysname"
  144.                 + "\n"
  145.                 + "\n"
  146.                 + "You can also find information on these commands writing: help. infront of the command, example: help.cpuname");
  147.             }
  148.             #endregion
  149.  
  150.             if (richTextBox8.Text == "clear")
  151.             {
  152.                 richTextBox8.Clear();
  153.                 richTextBox9.Clear();
  154.             }
  155.  
  156.             #region CPU Commands
  157.  
  158.             #region CPUName
  159.             if (richTextBox8.Text == "cpuname")
  160.                 {
  161.                     foreach (ManagementObject mo in mos.Get())
  162.                         {
  163.                             richTextBox8.Clear();
  164.                             richTextBox9.Clear();
  165.                             richTextBox9.AppendText(string.Format("{0}", (string)(mo["Name"])));
  166.                         }
  167.                 }
  168.             if (richTextBox8.Text == "help.cpuname")
  169.             {
  170.                 richTextBox9.Clear();
  171.                 richTextBox9.AppendText("cpuname: This command shows you the CPU company name, model and default speed.");
  172.                 richTextBox8.Clear();
  173.             }
  174.             #endregion
  175.  
  176.             #region SystemName
  177.             if (richTextBox8.Text == "sysname")
  178.             {
  179.                 foreach (ManagementObject mo in mos.Get())
  180.                 {
  181.                     richTextBox8.Clear();
  182.                     richTextBox9.Clear();
  183.                     richTextBox9.AppendText(string.Format("{0}", mo["SystemName"]).ToString());
  184.                 }
  185.             }
  186.             if (richTextBox8.Text == "help.sysname")
  187.             {
  188.                 richTextBox9.Clear();
  189.                 richTextBox9.AppendText("sysname: This command shows you the Name of the current SYSTEM this application is running on.");
  190.                 richTextBox8.Clear();
  191.             }
  192.             #endregion
  193.  
  194.             #region Family
  195.             if (richTextBox8.Text == "family")
  196.             {
  197.                 foreach (ManagementObject mo in mos.Get())
  198.                 {
  199.                     richTextBox9.Clear();
  200.                     richTextBox8.Clear();
  201.                     richTextBox9.AppendText(string.Format("Family : {0}", (ushort)mo["Family"]));
  202.                 }
  203.             }
  204.             if (richTextBox8.Text == "help.family")
  205.             {
  206.                 richTextBox9.Clear();
  207.                 richTextBox8.Clear();
  208.                 richTextBox9.AppendText("family: This command shows you the Processor family type, values mean:"
  209.                 + "\n"
  210.                 + "\n"
  211.                 + "1 = Other"
  212.                 + "\n"
  213.                 + "2 = Unknown"
  214.                 + "\n"
  215.                 + "13 = Pentium"
  216.                 + "\n"
  217.                 + "15 = Celeron"
  218.                 + "\n"
  219.                 + "\n"
  220.                 + "Visit http://msdn.microsoft.com/en-us/library/aa394373(VS.85).aspx for a better understanding");
  221.             }
  222.             #endregion
  223.  
  224.             #region Cores
  225.             if (richTextBox8.Text == "cpucores")
  226.             {
  227.                 foreach (ManagementObject mo in mos.Get())
  228.                 {
  229.                     richTextBox9.Clear();
  230.                     richTextBox8.Clear();
  231.                     richTextBox9.AppendText(string.Format("NumberOfCores : {0}", mo["NumberOfCores"]).ToString());
  232.                 }
  233.             }
  234.             if (richTextBox8.Text == "help.cpucores")
  235.             {
  236.                 richTextBox9.Clear();
  237.                 richTextBox8.Clear();
  238.                 richTextBox9.AppendText("cpucores: This command shows you the ammount of Cores for the current processor, physical cores not logic (Hyperthreading won't count).");
  239.             }
  240.             #endregion Cores
  241.  
  242.             #region Logical Cores
  243.             if (richTextBox8.Text == "logicalcores")
  244.             {
  245.                 foreach (ManagementObject mo in mos.Get())
  246.                 {
  247.                     richTextBox9.Clear();
  248.                     richTextBox8.Clear();
  249.                     richTextBox9.AppendText(string.Format("NumberOfLogicalProcessors : {0}", mo["NumberOfLogicalProcessors"]).ToString());
  250.                 }
  251.             }
  252.             if (richTextBox8.Text == "help.logicalcores")
  253.             {
  254.                 richTextBox9.Clear();
  255.                 richTextBox8.Clear();
  256.                 richTextBox9.AppendText("logicalcores: This command shows you the Number of logical processors for the current instance of the processor, this includes Threads for HyperThreading technology.");
  257.             }
  258.             #endregion
  259.  
  260.             #region CPU Type
  261.             if (richTextBox8.Text == "cputype")
  262.             {
  263.                 foreach (ManagementObject mo in mos.Get())
  264.                 {
  265.                     richTextBox9.Clear();
  266.                     richTextBox8.Clear();
  267.                     richTextBox9.AppendText(string.Format("ProcessorType : {0}", (ushort)mo["ProcessorType"]));
  268.                 }
  269.             }
  270.             if (richTextBox8.Text == "help.cputype")
  271.             {
  272.                 richTextBox9.Clear();
  273.                 richTextBox8.Clear();
  274.                 richTextBox9.AppendText("cputype: This command shows you the Primary function of the processor in your motherboard, values include:"
  275.                 + "\n"
  276.                 + "\n"
  277.                 + "1 = Other"
  278.                 + "3 = Central Processor"
  279.                 + "4 = Math Processor"
  280.                 + "5 = DSP Processor"
  281.                 + "6 = Video Processor");
  282.             }
  283.             #endregion
  284.  
  285.             #endregion
  286.  
  287.             #region GPU Commands
  288.  
  289.             #region GPUName
  290.             if (richTextBox8.Text == "gpuname")
  291.             {
  292.                 foreach (ManagementObject mo in gpu.Get())
  293.                 {
  294.                     richTextBox9.Clear();
  295.                     richTextBox8.Clear();
  296.                     richTextBox9.AppendText(string.Format("{0}", (string)(mo["Name"])));
  297.                 }
  298.             }
  299.             if (richTextBox8.Text == "help.gpuname")
  300.             {
  301.                 richTextBox9.Clear();
  302.                 richTextBox8.Clear();
  303.                 richTextBox9.AppendText("gpuname: This command shows you the GPU company and model");
  304.             }
  305.             #endregion
  306.  
  307.             #region GPUDriver
  308.             if (richTextBox8.Text == "gpudriver")
  309.             {
  310.                 foreach (ManagementObject mo in gpu.Get())
  311.                 {
  312.                     richTextBox9.Clear();
  313.                     richTextBox8.Clear();
  314.                     richTextBox9.AppendText(string.Format("{0}", (string)(mo["DriverVersion"])));
  315.                 }
  316.             }
  317.             if (richTextBox8.Text == "help.gpudriver")
  318.             {
  319.                 richTextBox9.Clear();
  320.                 richTextBox8.Clear();
  321.                 richTextBox9.AppendText("gpuname: This command shows you the GPU driver details");
  322.             }
  323.             #endregion
  324.  
  325.             #region GPU RF rate
  326.             if (richTextBox8.Text == "gpurefresh")
  327.             {
  328.                 foreach (ManagementObject mo in gpu.Get())
  329.                 {
  330.                     richTextBox9.Clear();
  331.                     richTextBox8.Clear();
  332.                     richTextBox9.AppendText("Current Refresh Rate: " + string.Format("{0}", mo["CurrentRefreshRate"]).ToString());
  333.                     richTextBox9.AppendText("\n" + "Max Refresh Rate: " + string.Format("{0}", mo["MaxRefreshRate"]).ToString());
  334.                 }
  335.             }
  336.             if (richTextBox8.Text == "help.gpurefresh")
  337.             {
  338.                 richTextBox9.Clear();
  339.                 richTextBox8.Clear();
  340.                 richTextBox9.AppendText("gpurefresh: This command shows you the GPU refresh rate which it is currently running at.");
  341.             }
  342.             #endregion
  343.  
  344.             #region Resolution
  345.             if (richTextBox8.Text == "resolution")
  346.             {
  347.                 foreach (ManagementObject mo in gpu.Get())
  348.                 {
  349.                     richTextBox9.Clear();
  350.                     richTextBox8.Clear();
  351.                     richTextBox9.AppendText(string.Format("{0}", mo["CurrentHorizontalResolution"]).ToString());
  352.                     richTextBox9.AppendText(" x ");
  353.                     richTextBox9.AppendText(string.Format("{0}", mo["CurrentVerticalResolution"]).ToString());
  354.                     if (richTextBox9.Text == "3840 x 2160")
  355.                     {
  356.                         richTextBox9.AppendText(" = 2160p (aka 4k)");
  357.                     }
  358.                     if (richTextBox9.Text == "2560 x 1440")
  359.                     {
  360.                         richTextBox9.AppendText(" = 1440p (aka 2k)");
  361.                     }
  362.                     if (richTextBox9.Text == "1920 x 1080")
  363.                     {
  364.                         richTextBox9.AppendText(" - 1080p");
  365.                     }
  366.                     if (richTextBox9.Text == "1280 x 720")
  367.                     {
  368.                         richTextBox9.AppendText(" - 720p");
  369.                     }
  370.                     if (richTextBox9.Text == "640 × 480")
  371.                     {
  372.                         richTextBox9.AppendText(" - Damnnn! It's 2014, you need to upgrade soon!");
  373.                     }
  374.                 }
  375.             }
  376.             if (richTextBox8.Text == "help.resolution")
  377.             {
  378.                 richTextBox9.Clear();
  379.                 richTextBox8.Clear();
  380.                 richTextBox9.AppendText("resolution: This command shows you the Resolution your card is outputting on your monitor."
  381.                 + "\n"
  382.                 + "\n"
  383.                 + "Common Resolutions:"
  384.                 + "\n"
  385.                 + "640 x 480 = 480p"
  386.                 + "\n"
  387.                 + "1280 x 720 = 720p"
  388.                 + "\n"
  389.                 + "1920 x 1080 = 1080p (aka Full HD)"
  390.                 + "\n"
  391.                 + "2560 x 1440 = 1440p (aka 2k)"
  392.                 + "\n"
  393.                 + "3840 x 2160 = 2160p (aka 4K aka big lad/lass resolution");
  394.             }
  395.             #endregion
  396.  
  397.             #endregion
  398.  
  399.             #region BIOS Commands
  400.  
  401.             if (richTextBox8.Text == "biosinfo")
  402.             {
  403.                 foreach (ManagementObject mo in bios.Get())
  404.                 {
  405.                     richTextBox8.Clear();
  406.                     richTextBox9.Clear();
  407.                     richTextBox9.AppendText(string.Format("Version: {0}", (string)(mo["Version"])) + "\n");
  408.                     richTextBox9.AppendText(string.Format("Manufacturer: {0}", (string)(mo["Manufacturer"])) + "\n" + "\n");
  409.                     richTextBox9.AppendText(string.Format("{0}", (string)(mo["Name"])) + "\n" + "Serial Number: " +(mo["SerialNumber"]));
  410.                 }
  411.             }
  412.             if (richTextBox8.Text == "help.biosinfo")
  413.             {
  414.                 richTextBox9.Clear();
  415.                 richTextBox8.Clear();
  416.                 richTextBox9.AppendText("biosinfo: This command shows you some information about the Bios itself.");
  417.             }
  418.  
  419.             #endregion
  420.  
  421.             #region FAN Commands
  422.             if (richTextBox8.Text == "faninfo")
  423.             {
  424.                 foreach (ManagementObject mo in fan.Get())
  425.                 {
  426.                     richTextBox8.Clear();
  427.                     richTextBox9.Clear();
  428.                     richTextBox9.AppendText(string.Format("Description: {0}", (string)(mo["Description"])) + "\n");
  429.                     richTextBox9.AppendText(string.Format("Name: {0}", (string)(mo["Name"])) + "\n" + "Active: " + mo["ActiveCooling"] + "\n");
  430.                     richTextBox9.AppendText(string.Format("Availability: {0}", mo["Availability"]).ToString() + "\n" + "1 = Other, 3 = Running/Full, 4 = Warning, 7 = Power Off");
  431.                 }
  432.             }
  433.             if (richTextBox8.Text == "help.faninfo")
  434.             {
  435.                 richTextBox9.Clear();
  436.                 richTextBox8.Clear();
  437.                 richTextBox9.AppendText("faninfo: This command shows you some information about the Fan on your CPU cooler.");
  438.             }
  439.             #endregion
  440.  
  441.             #region RAM Commands
  442.             if (richTextBox8.Text == "raminfo")
  443.             {
  444.                 foreach (ManagementObject mo in ram.Get())
  445.                 {
  446.                     richTextBox8.Clear();
  447.                     richTextBox9.Clear();
  448.                     richTextBox9.AppendText(string.Format("Description: {0}", (string)(mo["Description"])) + "\n" + "Manufacturer: " + (mo["Manufacturer"]) + "\n" + "Model: " + (mo["Model"]) + "\n");
  449.                     richTextBox9.AppendText(string.Format("Speed: {0}", mo["Speed"]).ToString() + "mhz");
  450.                 }
  451.             }
  452.             if (richTextBox8.Text == "help.raminfo")
  453.             {
  454.                 richTextBox9.Clear();
  455.                 richTextBox8.Clear();
  456.                 richTextBox9.AppendText("raminfo: This command shows you some information about the RAM installed in your system.");
  457.             }
  458.             #endregion
  459.  
  460.             #region SOUND Commands
  461.             if (richTextBox8.Text == "soundinfo")
  462.             {
  463.                 foreach (ManagementObject mo in sound.Get())
  464.                 {
  465.                     richTextBox8.Clear();
  466.                     richTextBox9.Clear();
  467.                     richTextBox9.AppendText(string.Format("Description: {0}", (string)(mo["Description"])) + "\n" + "Manufacturer: " + (mo["Manufacturer"]) + "\n" + "ProductName: " + (mo["ProductName"]) + "\n");
  468.                 }
  469.             }
  470.             if (richTextBox8.Text == "help.soundinfo")
  471.             {
  472.                 richTextBox9.Clear();
  473.                 richTextBox8.Clear();
  474.                 richTextBox9.AppendText("soundinfo: This command shows you some information about the Sound Device on your motherboard, if a GPU is installed, it may recognize the audio from it.");
  475.             }
  476.             #endregion
  477.         }
  478.  
  479.         private void button6_Click(object sender, EventArgs e)
  480.         {
  481.             richTextBox9.Clear();
  482.             richTextBox8.Clear();
  483.         }
  484.  
  485.         private void button5_Click(object sender, EventArgs e)
  486.         {
  487.             richTextBox8.Clear();
  488.         }
  489.  
  490.         private void richTextBox10_TextChanged(object sender, EventArgs e)
  491.         {
  492.  
  493.         }
  494.  
  495.         private void richTextBox12_TextChanged(object sender, EventArgs e)
  496.         {
  497.  
  498.         }
  499.  
  500.         // Hor and Vertical Sizes
  501.         private void button7_Click(object sender, EventArgs e)
  502.         {
  503.             MessageBox.Show("Resolutions" + "\n" + "1920x1080 = 1080P" + "\n" + "1280 x 720 = 720p", "Resolution of Screen");
  504.         }
  505.  
  506.         // Refresh Rate
  507.         private void button8_Click(object sender, EventArgs e)
  508.         {
  509.             MessageBox.Show("Refresh Rate:" + "\n" + "Normally your Video card is running the same as the Refresh rate as your Monitor" + "\n" + "Refresh rate is measured in Hz", "Refresh Rate");
  510.         }
  511.  
  512.         // Max Refresh Rate
  513.         private void button9_Click(object sender, EventArgs e)
  514.         {
  515.             MessageBox.Show("Max Refresh Rate:" + "\n" + "means the MAX hz the Video card can push through to your monitor", "Max Refresh Rate");
  516.         }
  517.  
  518.         private void richTextBox16_TextChanged(object sender, EventArgs e)
  519.         {
  520.         }
  521.  
  522.         private void button10_Click(object sender, EventArgs e)
  523.         {
  524.         }
  525.  
  526.         private void textBox1_TextChanged_2(object sender, EventArgs e)
  527.         {
  528.         }
  529.  
  530.         private void textBox1_TextChanged_3(object sender, EventArgs e)
  531.         {
  532.         }
  533.  
  534.         private void button10_Click_1(object sender, EventArgs e)
  535.         {
  536.         }
  537.  
  538.         private void richTextBox16_TextChanged_1(object sender, EventArgs e)
  539.         {
  540.         }
  541.     }
  542. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement