Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7004701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:13:59+00:00 2026-05-27T21:13:59+00:00

My program performs a task on the hard disk free space. The task is

  • 0

My program performs a task on the hard disk free space.
The task is quite long, it takes 1-2 hours.

The problem is that on laptop the hard disk may be turned off after few minutes when the user is inactive.

How do I programmatically prevent Windows from hard disk spin down (power off) ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:13:59+00:00Added an answer on May 27, 2026 at 9:13 pm

    To prevent the system from entering idle mode you may try to use the SetThreadExecutionState function. This function informs the system that the application is in use and allows you to specify the thread’s execution requirements. The usage can be like this, but I’m not sure if this affects also the disk power down timer:

    type
      EXECUTION_STATE = DWORD;
    
    const
      ES_SYSTEM_REQUIRED = $00000001;
      ES_DISPLAY_REQUIRED = $00000002;
      ES_USER_PRESENT = $00000004;
      ES_AWAYMODE_REQUIRED = $00000040;
      ES_CONTINUOUS = $80000000;
    
    function SetThreadExecutionState(esFlags: EXECUTION_STATE): EXECUTION_STATE;
      stdcall; external 'kernel32.dll' name 'SetThreadExecutionState';
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      if SetThreadExecutionState(ES_CONTINUOUS or ES_SYSTEM_REQUIRED or
        ES_AWAYMODE_REQUIRED) <> 0 then
      try
        // execute your long running task here
      finally
        SetThreadExecutionState(ES_CONTINUOUS);
      end;
    end;
    

    Or there is also available the new set of functions PowerCreateRequest, PowerSetRequest and PowerClearRequest designed for Windows 7, but the documentation is confusing and I haven’t found any example of their usage at this time.

    Or you can modify the power settings by PowerWriteACValueIndex or PowerWriteDCValueIndex functions with the GUID_DISK_SUBGROUP subgroup of power settings.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program which performs a useful task. Now I want to produce
I am writing a program that performs different string operations on every letter of
I have a database-synchronisation task that takes some time to process, as there are
I've a main program which performs some task in Java. I want to run
I am trying to create a program where it performs some task and exits.
I have a program which deliberately performs a divide by zero (and stores the
How should I perform garbage collection in a program that consists of multiple threads
I have a program that loads a file (anywhere from 10MB to 5GB) a
I have an executable that is started by a windows service, this program will
I recently wrote a small number-crunching program that basically loops over an N-dimensional grid

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.