Display the showdown dialog

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.  

horridAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
OnegaZhangConnect With a Mentor Commented:
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
 
SteHCommented:
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
 
horridAuthor Commented:
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
 
Jaime OlivaresConnect With a Mentor Software ArchitectCommented:
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
 
horridAuthor Commented:
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
All Courses

From novice to tech pro — start learning today.