[DllImport("kernel32.dll")]
static extern bool GetDevicePowerState(IntPtr hDevice, out bool pfOn);
None.
None.
Please add some!
// Get the power state of a harddisk (From http://msdn.microsoft.com/en-us/library/ms704147.aspx)
string ReportDiskStatus()
{
string status = string.Empty;
bool fOn = false;
Assembly assembly = Assembly.GetExecutingAssembly();
FileStream[] files = assembly.GetFiles();
if (files.Length > 0)
{
IntPtr hFile = files[0].Handle;
bool result = GetDevicePowerState(hFile, out fOn);
if (result)
{
if (fOn)
{
status = "Disk is powered up and spinning";
}
else
{
status = "Disk is sleeping";
}
}
else
{
status = "Cannot get Disk Status";
}
Console.WriteLine(status);
}
return status;
}
Do you know one? Please contribute it!