Attributes of a physical disk. Windows only.
Inheritance: Attributes, IDescribable
		public WinPhysicalDisk(ManagementObject mo) {
			Attributes = new PhysicalDiskAttributes(mo);

			Handle = Win32.CreateFile(Attributes.DeviceID, EFileAccess.GenericRead, EFileShare.Read | EFileShare.Write | EFileShare.Delete, IntPtr.Zero, ECreationDisposition.OpenExisting, EFileAttributes.None, IntPtr.Zero);

			if (Handle.IsInvalid) {
				throw new Exception("Failed to get a handle to the physical disk. " + Marshal.GetLastWin32Error());
			}
			_size = Util.GetDiskSize(Handle);

			GetDiskSections();
		}
示例#2
0
        public WinPhysicalDisk(ManagementObject mo)
        {
            Attributes = new PhysicalDiskAttributes(mo);

            Handle = Win32.CreateFile(Attributes.DeviceID, EFileAccess.GenericRead, EFileShare.Read | EFileShare.Write | EFileShare.Delete, IntPtr.Zero, ECreationDisposition.OpenExisting, EFileAttributes.None, IntPtr.Zero);

            if (Handle.IsInvalid)
            {
                throw new Exception("Failed to get a handle to the physical disk. " + Marshal.GetLastWin32Error());
            }
            _size = Util.GetDiskSize(Handle);

            GetDiskSections();
        }