示例#1
0
        public RAM()
        {
            int counter = 0;
            ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_PhysicalMemory");

            ManagementObjectCollection searchList = searcher.Get();

            this.numModules = searcher.Get().Count;
            this.installedRAM = new RAM[numModules];

            foreach (ManagementObject mo in searchList)
            {
                installedRAM[counter] = new RAM(counter);
                try
                {
                    installedRAM[counter].SetManufacturer(mo["manufacturer"].ToString().Trim());
                }
                catch (Exception e)
                {
                    installedRAM[counter].SetManufacturer("none");
                }

                try
                {
                    installedRAM[counter].SetModel(mo["partnumber"].ToString().Trim());
                }
                catch (Exception e)
                {
                    installedRAM[counter].SetModel("none");
                }

                try
                {
                    installedRAM[counter].SetID(mo["serialnumber"].ToString().Trim());
                }
                catch (Exception e)
                {
                    installedRAM[counter].SetID("none");
                }

                try
                {
                    installedRAM[counter].speed = mo["speed"].ToString().Trim() + "MHz";
                }
                catch (Exception e)
                {
                    installedRAM[counter].speed = "none";
                }

                try
                {
                    installedRAM[counter].moduleSize = long.Parse(mo["capacity"].ToString().Trim()) / 1048576;
                }
                catch (Exception e)
                {
                    installedRAM[counter].moduleSize = 0;
                }
                counter++;
            }
        }
示例#2
0
        public void Init()
        {
            // TODO: Complete member initialization
            Console.WriteLine("Getting CPU Information");
            compCPU = new CPU();

            Console.WriteLine("Getting Motherboard Information");
            compMobo = new Motherboard();

            Console.WriteLine("Getting RAM Information");
            compRAM = new RAM();

            Console.WriteLine("Getting Drive Information");
            compVols = new Volumes();

            Console.WriteLine("Getting Display Adapter Information");
            compDisplays = new DisplayDevices();

            Console.WriteLine("Getting NIC Information");
            compNICS = new NIC();

            Console.WriteLine("Getting Service Information");
            //Getting services information
            UpdateServices();
            Console.WriteLine("Init Complete");
        }
示例#3
0
 public void InitComputer()
 {
     computer.Init();
     compHardware = computer.GetHardware();
     compCPU = (CPU)compHardware[0];
     compMobo = (Motherboard)compHardware[1];
     compRAM = (RAM)compHardware[2];
     compVols = (Volumes)compHardware[3];
     compDisplay = (DisplayDevices)compHardware[4];
     compNIC = (NIC)compHardware[5];
 }