Spin Down Hard Disk Programmatically on Windows?

前端 未结 5 389
名媛妹妹
名媛妹妹 2021-02-01 19:44

How do you request Windows to spin down a hard disk programmatically? Is there any user-mode function I can call (or kernel-mode function to call or IRP to send) in order to mak

5条回答
  •  醉梦人生
    2021-02-01 20:25

    While there is no apparent way to do what you're asking for (i.e. tell power management "act as if the timer for spinning down the disk has expired"), there may be a couple ways to simulate it:

    1. Call FlushFileBuffers on the drive (you need to be elevated to open \\.\C), then issue the STANDBY command to the drive.

    2. Make the API call that sets the timeout for spinning down the disk to 1 second, then increase it back to its former value after 1 second. Note that you may need to ramp up to the former value rather than immediately jump to it.

提交回复
热议问题