开发者

Windows - put HDD stand-by and sleep mode

How can I put a hard disk drive in stand-by or sleep mode in Windows, in a programmatic manner.

Does the Windows API or any .Net libraries provide any functions to achieve this? (I am aware that I should probably not interfere with Windows's power management mechanism, but this is not something I intend to use in a production environment, it is a proof of concept fo开发者_如何转开发r some algorithms).


I found a program called "RevoSleep". Warning: MUSIC! http://revosleep.realspooky.de/

I can't tell you if it works at all [I'm not gutsy enough to try :) ] but I did try decompiling it with the .NET Reflector. Which, lo and behold, worked. (I can't find what this thing is licensed under so beware.)

Without really knowing what I'm looking at, these snippets seemed most relevant. They all use the Windows api function DeviceIoControl.

"Sleep" drive:

if (Environment.OSVersion.Version.Build > 0xa28)
{
    num2 = DeviceIoControl(this.hDevice[0], 0x4d02c, (void*) &_ata_pass_through_ex_with_buffer, 40, (void*) &_ata_pass_through_ex_with_buffer, 40, (uint modopt(IsLong)*) &num11, null);
}
else
{
    num2 = DeviceIoControl(this.hDevice[0], 0x4d028, (void*) &_ata_pass_through, 0x20c, (void*) &_ata_pass_through, 0x20c, (uint modopt(IsLong)*) &num11, null);
    //...
}

"Lock" drive:

DeviceIoControl(hDevice[index], 0x90018, null, 0, null, 0, (uint modopt(IsLong)*) &num11, null);

"Deactivate" drive:

DeviceIoControl(this.hDevice[0], 0x2d1080, null, 0, (void*) &_storage_device_number2, 12, (uint modopt(IsLong)*) &num8, null);

"Put volume in offline state"(?):

DeviceIoControl(this.hDevice[num3], 0x56c00c, null, 0, null, 0, (uint modopt(IsLong)*) &num11, null);

Which, again, I have no idea if that works or is even what you're looking for. You could always try decompiling it and looking at all the code yourself.

Alternately, do any of these api calls help?
SetSuspend function
GetPwrDiskSpindownRange function

Good luck.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜