Exemplo n.º 1
0
        public List <Drive> GetDriveInfo()
        {
            DriveInfo[] allDrives = DriveInfo.GetDrives();

            List <Drive> listOfDrives = new List <Drive>();

            foreach (var drive in allDrives)
            {
                if (drive.IsReady)
                {
                    Drive driveInfo = new Drive
                    {
                        Name      = drive.Name,
                        Label     = drive.VolumeLabel,
                        Format    = drive.DriveFormat,
                        Type      = drive.DriveType.ToString(),
                        FreeSpace = Calculators.DiskSpaceBytesCalc(drive.TotalFreeSpace, false)
                    };

                    listOfDrives.Add(driveInfo);
                }
            }

            return(listOfDrives);
        }
Exemplo n.º 2
0
        public List <Ram> GetRamInfo()
        {
            ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_OperatingSystem");
            ManagementObjectSearcher   searcher = new ManagementObjectSearcher(query);
            ManagementObjectCollection results  = searcher.Get();

            List <Ram> rams = new List <Ram>();

            foreach (ManagementObject result in results)
            {
                Ram ram = new Ram
                {
                    TotalVisable =
                        Calculators.DiskSpaceBytesCalc(Convert.ToDecimal(result["TotalVisibleMemorySize"]), true),
                    FreeVisable  = Calculators.DiskSpaceBytesCalc(Convert.ToDecimal(result["FreePhysicalMemory"]), true),
                    TotalVirtual =
                        Calculators.DiskSpaceBytesCalc(Convert.ToDecimal(result["TotalVirtualMemorySize"]), true),
                    freeVirtual = Calculators.DiskSpaceBytesCalc(Convert.ToDecimal(result["FreeVirtualMemory"]), true)
                };
                rams.Add(ram);
            }
            ;

            return(rams);
        }