using System; using System.Management; namespace Trigger.Classes.Device { /// /// The Win32_CDROMDrive WMI class represents a CD-ROM drive on a computer system running Windows. Be aware that the name of the drive does not correspond to the logical drive letter assigned to the device. /// public class CdRomDrive : StorageDisk { #region Enums /// /// The availabilitys of the /// public enum Availabilities : ushort { /// Other = 0x1, /// Unknown = 0x2, /// Running / Full power Running_FullPower = 0x3, /// Warning = 0x4, /// InTest = 0x5, /// NotApplicable = 0x6, /// PowerOff = 0x7, /// OffLine = 0x8, /// OffDuty = 0x9, /// Degraded = 0xA, /// NotInstalled = 0xB, /// InstallError = 0xC, /// The device is known to be in a power save mode, but its exact status is unknown. PowerSave_Unknown = 0xD, /// The device is in a power save state but still functioning, and may exhibit degraded performance. PowerSave_LowPowerMode = 0xE, /// The device is not functioning, but could be brought to full power quickly. PowerSave_Standby = 0xF, /// PowerCycle = 0x10, /// The device is in a warning state, though also in a power save mode. PowerSave_Warning = 0x11, } /// /// The capability of the /// public enum Capabilitiy : ushort { /// Unknown = 0, /// Other = 1, /// SequentialAccess = 2, /// RandomAccess = 3, /// SupportsWriting = 4, /// Encryption = 5, /// Compression = 6, /// SupportsRemovableMedia = 7, /// ManualCleaning = 8, /// AutomaticCleaning = 9, /// SMARTNotification = 10, /// SupportsDualSidedMedia = 11, /// PredismountEjectNotRequired = 12, } /// /// Errors and their codes that the config manager can return /// public enum ConfigManagerErrorCodes : uint { ///Device is working properly. OK = 0x0, ///Device is not configured correctly. Misconfigured = 0x1, ///Windows cannot load the driver for this device. DriversNotLoaded = 0x2, ///Driver for this device might be corrupted, or the system may be low on memory or other resources. CorruptDrivers = 0x3, ///Device is not working properly. One of its drivers or the registry might be corrupted. DriverOrRegistryCorrupted = 0x4, ///Driver for the device requires a resource that Windows cannot manage. UnmanagableResourceRequired = 0x5, ///Boot configuration for the device conflicts with other devices. BootConfigConflict = 0x6, ///Cannot filter. Unfilterable = 0x7, ///Driver loader for the device is missing. DriverLoaderMissing = 0x8, ///Device is not working properly. The controlling firmware is incorrectly reporting the resources for the device. FirmwareError = 0x9, ///Device cannot start. CannotStart = 0xA, ///Device failed. Failed = 0xB, ///Device cannot find enough free resources to use. NoMemory = 0xC, ///Windows cannot verify the device's resources. VerifyResourcesFailed = 0xD, ///Device cannot work properly until the computer is restarted. RestartRequired = 0xE, ///Device is not working properly due to a possible re-enumeration problem. ReEnumerationProblem = 0xF, ///Windows cannot identify all of the resources that the device uses. NotAllResourcesIdentified = 0x10, ///Device is requesting an unknown resource type. UnknownResourceRequested = 0x11, ///Device drivers must be reinstalled. ReinstallDriver = 0x12, ///Failure using the VxD loader. VxDLoaderFailed = 0x13, ///Registry might be corrupted. RegistryCorrupted = 0x14, ///System failure. If changing the device driver is ineffective, see the hardware documentation. Windows is removing the device. SystemFailure = 0x15, ///Device is disabled. DeviceDisabled = 0x16, ///System failure. If changing the device driver is ineffective, see the hardware documentation. SystemFailure2 = 0x17, ///Device is not present, not working properly, or does not have all of its drivers installed. NotPresent = 0x18, ///Windows is still setting up the device. SettingUp = 0x19, ///Windows is still setting up the device. SettingUp2 = 0x1A, ///Device does not have valid log configuration. InvalidLogConfig = 0x1B, ///Device drivers are not installed. NoDrivers = 0x1C, ///Device is disabled. The device firmware did not provide the required resources. FirmwareResourceError = 0x1D, ///Device is using an IRQ resource that another device is using. IrqResourceConflict = 0x1E, ///Device is not working properly. Windows cannot load the required device drivers. DriversNotLoaded2 = 0x1F, } #endregion #region Properties /// Availabilities and status of the device. public Availabilities Availability { get; internal set; } /// Array of capabilities of the media access device. public ushort[] Capabilities { get; internal set; } /// Short description of the object—a one-line string. public string Caption { get; internal set; } /// Windows Configuration Manager error code. public ConfigManagerErrorCodes ConfigManagerErrorCode { get; internal set; } /// Manufacturer of the Windows CD-ROM drive. public string Manufacturer { get; internal set; } /// Maximum size, in kilobytes, of media supported by this device. public ulong MaxMediaSize { get; internal set; } /// If True, a CD-ROM is in the drive. public bool MediaLoaded { get; internal set; } /// /// Type of media that can be used or accessed by this device. /// /// CdRomOnly, CdRomWrite, DVDRomOnly, DVDRomWrite public string MediaType { get; internal set; } /// /// Transfer rate of the CD-ROM drive. A value of -1 indicates that the rate cannot be determined. When this happens, the CD is not in the drive. (kB/s) /// public double TransferRate { get; internal set; } #endregion #region Constructors /// /// Initialize a new instance with the given values. /// /// public CdRomDrive(ManagementObject mo) : base(mo["DeviceId"].ToString(), mo["Name"].ToString(), mo["Caption"].ToString()) { this.Type = DeviceType.CD; this.Availability = (Availabilities)mo["Availability"]; this.Capabilities = (ushort[])mo["Capabilities"]; this.Caption = mo["Caption"].ToString(); this.ConfigManagerErrorCode = (ConfigManagerErrorCodes)mo["ConfigManagerErrorCode"]; this.Manufacturer = mo["Manufacturer"].ToString(); this.MediaLoaded = Convert.ToBoolean(mo["MediaLoaded"]); this.MediaType = mo["MediaType"].ToString(); this.TransferRate = (double)mo["TransferRate"]; } #endregion } }