Solved

Display the showdown dialog

Posted on 2004-10-27
351 Views
Last Modified: 2012-06-27
I am working on a hardware project and one of the functions of the device is to bring up the Window shutdown dialog, the user then selects the option they want just like they would if they selected start -> shutdown.
It seems its easy enough to shut down the computer directly but I can't find any solution to just display the standard dialog.  

0
Question by:horrid
    5 Comments
     
    LVL 13

    Expert Comment

    by:SteH
    And what about duplicating this dialog? A combo with 4 or 5 elements should not be too difficult. It will only be your design and not the standard OS one in that case.
    0
     

    Author Comment

    by:horrid
    I am trying to avoid too much in the way of custom interfaces.  The user should not have constant reminders that they are running some special hardware device.  

    In VB it looks like you can do it like this
    Private Declare Function SHShutDownDialog Lib "shell32" Alias "#60" (ByVal something As Long) As Long

    SHShutDownDialog 0

    I'm still new to C++ and have no idea how to convert that over.  

    I'll would like to avoid a custom dialog if I can, the hardware device is not ment to be obvious that you are running it.
    0
     
    LVL 12

    Accepted Solution

    by:
    typedef int (CALLBACK *SHUTDOWNDLG) (int);
    HINSTANCE hInst = LoadLibrary("shell32");
       SHUTDOWNDLG SHShutDownDialog;
       if(hInst != 0)
       {
       //get the address of SHShutDownDialog
       SHShutDownDialog = (SHUTDOWNDLG)GetProcAddress(hInst, (LPSTR)60);
       (*SHShutDownDialog)(0);
       FreeLibrary(hInst);
       }
    0
     
    LVL 55

    Assisted Solution

    by:Jaime Olivares
    The answer is here:
    http://www.cstudyhome.com/wenzhang06/ReadNews.asp?NewsID=3349

    I suppose is an OnegaZhang's page.
    There are some extra characters. Clean answer (the same) is this:

        typedef int (CALLBACK *SHUTDOWNDLG) (int);
        HINSTANCE hInst = LoadLibrary("shell32");
        SHUTDOWNDLG SHShutDownDialog;
        if(hInst) {
            SHShutDownDialog = (SHUTDOWNDLG)GetProcAddress(hInst, (LPSTR)60);
            (*SHShutDownDialog)(0);
            FreeLibrary(hInst);
        }    

    It is exactly equivalent to the Visual Basic solution you've posted.

    Good luck,
    Jaime.
    0
     

    Author Comment

    by:horrid
    Thanks!  This has opened me up to an entire new world!  Seeing how to implement a shell32 api call was by far the more important thing I got out of this.
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: JavaScript Coding - Massive 12-Part Bundle

    Regardless of your programming skill level, you'll go from basics to advanced concepts in a vast array of JavaScript subjects including Sammy.js, Agility.js, Ember.js, Node.js, jQuery, AJAX, Extjs, AngularJS, Knockout.js, and JSON.

    Suggested Solutions

    Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
    Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
    The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
    The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

    857 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now