CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2008
    Posts
    43

    HandlerEx function and SERVICE_CONTROL_POWEREVENT

    I'm experiencing a different behaviour from what is told in the docs:

    In my HandlerEx function of my custom service (registered with RegisterServiceCtrlHandlerEx) when I intercept the control event SERVICE_CONTROL_POWEREVENT the DWORD dwEventType is not PBT_POWERSETTINGCHANGE as stated in docs but can be any of the event identifiers of the WM_POWERBROADCAST Message even when i try to reproduce one of the power change PBT_POWERSETTINGCHANGE should dealing with...

    I suppose I'm doing something wrong, or not understanding docs well.
    Last edited by Enrorr; September 1st, 2008 at 10:58 AM.

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    894

    Re: HandlerEx function and SERVICE_CONTROL_POWEREVENT

    Quote Originally Posted by Enrorr
    the DWORD dwEventType is not PBT_POWERSETTINGCHANGE as stated in docs ... I suppose I'm doing something wrong, or not understanding docs well.
    I guess it is OS specific.

    For 2K/XP/Server 2003 (in case of SERVICE_CONTROL_POWEREVENT):

    - dwEventType parameter will be any of the values that could be pased in the wParam parameter of the WM_POWERBROADCAST message: http://msdn.microsoft.com/en-us/libr...47(VS.85).aspx

    - lpEventData points to the data that comes in the lParam parameter of the WM_POWERBROADCAST message.

    For Vista/Server 2008 (in case of SERVICE_CONTROL_POWEREVENT):

    - dwEventType parameter may be set to PBT_POWERSETTINGCHANGE;

    - in that case lpEventData points to POWERBROADCAST_SETTING structure:
    http://msdn.microsoft.com/en-us/libr...23(VS.85).aspx


    This is an ambiguous documentation. It should've said that it is only for Vista (that is what MSDN is now for).
    Last edited by dc_2000; August 24th, 2009 at 03:39 AM.

  3. #3
    Join Date
    Jun 2008
    Posts
    43

    Re: HandlerEx function and SERVICE_CONTROL_POWEREVENT

    Thank you, I should reached it by myself (me stupid).
    I'll try to define WINVER and _WIN32_WINNT as 0x0600.
    No real vista pc around here for miles

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured