At.FF.Krems.FullscreenBrowser.PowerManagement.DriveAsleep C# (CSharp) Method

DriveAsleep() public method

Checks is a HDD is currently sleeping (wound down).
public DriveAsleep ( int deviceId ) : bool
deviceId int Integer value for volume, e.g. 0.
return bool
        public bool DriveAsleep(int deviceId)
        {
            // call power state api and return if drive is asleep
            bool fOn, ret = true;
            var handle = GetDeviceHandle(deviceId);
            if (handle != IntPtr.Zero && NativeMethods.GetDevicePowerState(handle, out fOn))
            {
                ret = fOn;
            }

            NativeMethods.CloseHandle(handle);
            return !ret;
        }