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

    Stop Shutdown while working on my software

    Hi.
    I want to stop shutdown while my software is working. If anyone is pressing shutdown button my application have to prompt a message showing "whether u want to shutdown(Yes) or not(No)" If we press YES then only my computer have to shut down.


    I did with Platform SDK help but not working. Can u give sample

    case WM_QUERYENDSESSION:
    {
    int r;
    r = MessageBox(NULL, "Shut down?","WM_QUERYENDSESSION", MB_YESNO);

    // Return TRUE to allow shutdown, FALSE to stop.

    return r == IDYES;
    break;
    }

    THe above code i tried but didnt get any idea. Please help

    Thanks in advance

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Stop Shutdown while working on my software

    This is the correct use.

    Quote Originally Posted by MSDN
    If your application must block or postpone system shutdown, use the ShutdownBlockReasonCreate function.
    Try calling ShutdownBlockReasonCreate() when you don't want to system to be shut down, and ShutdownBlockReasonDestroy() when you want to allow the system to shut down.

    Also, on Vista and newer systems
    Quote Originally Posted by MSDN
    If an application returns FALSE in response to WM_QUERYENDSESSION, it still appears in the shutdown UI. Note that the system does not allow console applications or applications without a visible window to cancel shutdown. These applications are automatically terminated if they do not respond to WM_QUERYENDSESSION or WM_ENDSESSION within 5 seconds or if they return FALSE in response to WM_QUERYENDSESSION.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  3. #3
    Join Date
    Mar 2010
    Posts
    21

    Re: Stop Shutdown while working on my software

    you are saying very good information to me

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