예제 #1
0
        public HDDGroup(ISettings settings)
        {
            int p = (int)Environment.OSVersion.Platform;

            if (p == 4 || p == 128)
            {
                return;
            }

            for (int drive = 0; drive < MAX_DRIVES; drive++)
            {
                IntPtr handle = SMART.OpenPhysicalDrive(drive);

                if (handle == SMART.INVALID_HANDLE_VALUE)
                {
                    continue;
                }

                if (!SMART.EnableSmart(handle, drive))
                {
                    SMART.CloseHandle(handle);
                    continue;
                }

                string name = SMART.ReadName(handle, drive);
                if (name == null)
                {
                    SMART.CloseHandle(handle);
                    continue;
                }

                List <SMART.DriveAttribute> attributes =
                    new List <SMART.DriveAttribute>(SMART.ReadSmart(handle, drive));

                if (!(attributes.Count > 0))
                {
                    SMART.CloseHandle(handle);
                    continue;
                }

                SMART.SSDLifeID ssdLifeID = GetSSDLifeID(attributes);
                if (ssdLifeID == SMART.SSDLifeID.None)
                {
                    SMART.AttributeID temperatureID = GetTemperatureIndex(attributes);

                    if (temperatureID != 0x00)
                    {
                        hardware.Add(new HDD(name, handle, drive, temperatureID, settings));
                        continue;
                    }
                }
                else
                {
                    hardware.Add(new HDD(name, handle, drive, ssdLifeID, settings));
                    continue;
                }

                SMART.CloseHandle(handle);
            }
        }
예제 #2
0
        public HDD(string name, IntPtr handle, int drive, SMART.SSDLifeID lifeID,
                   ISettings settings)
        {
            this.name       = name;
            this.handle     = handle;
            this.drive      = drive;
            this.count      = 0;
            this.lifeID     = lifeID;
            this.lifeSensor = new Sensor("HDD", 0, SensorType.Level, this, settings);

            Update();
        }