dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Where is SetThreadExecutionState?

  1. #1
    Join Date
    Jan 2009
    Posts
    1,689

    Where is SetThreadExecutionState?

    Does anyone know what I have to include to use SetThreadExecutionState in MS Windows? I can't find any correct documentation. MSDN says to include Windows.h. Nope.

    Or, is there another way to prevent the system from going to sleep? I have a program that might run for days and the system can't go to sleep during that time.

  2. #2
    Join Date
    Apr 2009
    Posts
    598

    Re: Where is SetThreadExecutionState?

    Could you post your error messages?

    SetThreadExecutionState() is declared in winbase.h, itself included in windows.h

    But there is a restriction about it in winbase.h:
    #if (_WIN32_WINNT >= 0x0500 || _WIN32_WINDOWS >= 0x0410)

  3. #3
    Join Date
    Jan 2009
    Posts
    1,689

    Re: Where is SetThreadExecutionState?

    SetThreadExecutionState was not declared in scope.

    Hmm, that restriction seems to fail. How do I make it so that Windows can't go to sleep while my program is running then? Myself and my users use either Windows XP or Windows 7, so it only has to work on those platform. The company officially doesn't support <XP or Vista. Is there a way to do this?

    I also tried this:
    Code:
            case WM_POWERBROADCAST:
                if (lParam == PBT_APMQUERYSUSPEND){
                    return BROADCAST_QUERY_DENY;
                }
                return TRUE;
    But that didn't work, the message was caught and denied according to my log, but the computer went to sleep anyway.
    Last edited by ninja9578; March 29th, 2010 at 10:03 AM.

  4. #4
    Join Date
    Jul 2005
    Location
    Netherlands
    Posts
    2,042

    Re: Where is SetThreadExecutionState?

    The WINVER etc. macros are normally defined in stdafx.h. Either define them is such a common header file of define them in the project settings for each project. See http://msdn.microsoft.com/en-us/libr...45(VS.85).aspx
    Cheers, D Drmmr

    Please put [code][/code] tags around your code to preserve indentation and make it more readable.

    As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)