예제 #1
0
        public static RamInfo ReadRAMInfo()
        {
            RamInfo ram = new RamInfo();

            try
            {
                ManagementObjectSearcher    searcher = new ManagementObjectSearcher("SELECT BlockSize, StartingAddress, EndingAddress FROM Win32_MemoryDevice");
                Dictionary <string, string> data     = new Dictionary <string, string>();
                UInt64 endingAddress   = 0;
                UInt64 startingAddress = 0;

                foreach (ManagementObject queryObj in searcher.Get())
                {
                    ram.NumberOfDevice++;
                    if (queryObj["EndingAddress"] != null && queryObj["StartingAddress"] != null)
                    {
                        endingAddress   = UInt64.Parse(queryObj["EndingAddress"].ToString());
                        startingAddress = UInt64.Parse(queryObj["StartingAddress"].ToString());

                        float ramInThisStick = Util.ConvertKilobytesToMegabytes(endingAddress - startingAddress);
                        ram.Sizes.Add(ramInThisStick);
                        ram.TotalRAM += ramInThisStick;
                    }
                }
            }
            catch (Exception e)
            {
            }
            finally
            { }

            return(ram);
        }
예제 #2
0
        public static RamInfo ReadRAMInfo()
        {
            RamInfo ram = new RamInfo();
            try
            {
                ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT BlockSize, StartingAddress, EndingAddress FROM Win32_MemoryDevice");
                Dictionary<string, string> data = new Dictionary<string, string>();
                UInt64 endingAddress = 0;
                UInt64 startingAddress = 0;

                foreach (ManagementObject queryObj in searcher.Get())
                {
                    ram.NumberOfDevice++;
                    if (queryObj["EndingAddress"] != null && queryObj["StartingAddress"] != null)
                    {
                        endingAddress = UInt64.Parse(queryObj["EndingAddress"].ToString());
                        startingAddress = UInt64.Parse(queryObj["StartingAddress"].ToString());

                        float ramInThisStick = Util.ConvertKilobytesToMegabytes(endingAddress - startingAddress);
                        ram.Sizes.Add(ramInThisStick);
                        ram.TotalRAM += ramInThisStick;
                    }
                }
            }
            catch (Exception e)
            {

            }
            finally
            { }

            return ram;
        }