home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / SHUTDWN3.ZIP / SHUTDOWN.C next >
C/C++ Source or Header  |  1991-01-20  |  1KB  |  48 lines

  1. /* */
  2.  
  3. #define INCL_WIN
  4. #define DESKTOP_TASK "Desktop Manager"
  5. #define SHUTDOWN_ID  0x131L
  6.  
  7. #include <os2.h>
  8. #include <string.h>
  9.  
  10. int main( void )
  11.     {
  12.     HAB         hab;
  13.     HMQ         hmq;
  14.     USHORT        cTasks;
  15.     SEL         sel;
  16.     PSWBLOCK    pswblk;
  17.     USHORT        cbTaskListBuf;
  18.     USHORT        i;
  19.     HWND        hwndDesktopMgr;
  20.  
  21.     hab = WinInitialize( 0 );
  22.     hmq = WinCreateMsgQueue( hab, 0 );
  23.  
  24.     cTasks = WinQuerySwitchList( hab, NULL, 0 );
  25.     cbTaskListBuf = ( cTasks * sizeof (SWENTRY) ) + sizeof (HSWITCH);
  26.     DosAllocSeg( cbTaskListBuf, &sel, SEG_NONSHARED );
  27.     pswblk = MAKEP( sel, 0 );
  28.     WinQuerySwitchList( hab, pswblk, cbTaskListBuf );
  29.  
  30.     for ( i = 0; i < cTasks; i++ )
  31.         if ( _fstrcmp( pswblk -> aswentry[ i ].swctl.szSwtitle,
  32.                 DESKTOP_TASK ) == 0 )
  33.             break;
  34.  
  35.     hwndDesktopMgr    = pswblk -> aswentry[ i ].swctl.hwnd;
  36.     DosFreeSeg(sel);
  37.  
  38.     WinSetWindowPos( hwndDesktopMgr, HWND_TOP, 0, 0, 0, 0, SWP_RESTORE );
  39.     WinPostMsg( hwndDesktopMgr, WM_COMMAND, (MPARAM) SHUTDOWN_ID, (MPARAM) 0L );
  40.  
  41.     WinDestroyMsgQueue( hmq );
  42.     WinTerminate( hab );
  43.  
  44.     return ( 0 );
  45.     }
  46.  
  47.  
  48.