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(); }
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(); }