home *** CD-ROM | disk | FTP | other *** search
/ Prima Shareware 3 / DuCom_Prima-Shareware-3_cd1.bin / PROGRAMO / C / WINEXIT / WINEXIT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-18  |  17.9 KB  |  617 lines

  1. /*
  2.  * $Id: WINEXIT.C 1.0 1993/07/19 15:26:48 nino Exp $
  3.  *
  4.  * Copyright (c) 1993.  Nino Margetic.  All rights reserved.
  5.  *
  6.  *      General permission is hereby granted to copy this
  7.  *      program freely provided no charge is made for its
  8.  *      distribution and provided this copyright notice
  9.  *      remains in place.
  10.  *
  11.  * Abstract:    WINEXIT.C - Exit from Windows from an icon.
  12.  *
  13.  *    This program provides an easy way to get out of Windows.
  14.  *    It can be run either from the Program Manager or it can
  15.  *    be started and minimized so that its icon shows up in
  16.  *    the icon area.
  17.  *
  18.  * Operating procedures:
  19.  *
  20.  *    This program can be placed in a convenient group in the
  21.  *    Program Manager or it can be placed in the StartUp group
  22.  *    so that it shows up in the main icon area.  If it is put
  23.  *    in the StartUp group it should probably be run minimized.
  24.  *
  25.  * Written: 16-Jul-1993 Nino Margetic <nino@medphys.ucl.ac.uk>
  26.  *
  27.  * Acknowledgements:
  28.  *        Thanks to Bruce C. Wright and his EXIT utility which served
  29.  *        as a template for this exercise in Windows programming.
  30.  *
  31.  *
  32.  */
  33.  
  34. #define STRICT
  35. #define WIN31
  36.  
  37. #include <windows.h>
  38. #include <bwcc.h>
  39. #ifdef __BORLANDC__
  40. #pragma hdrstop
  41. #endif
  42.  
  43. #include "winexit.h"
  44.  
  45.  
  46.  
  47. /*
  48.  * Main procedure
  49.  */
  50. int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
  51.             LPSTR lpszCmdLine, int nCmdShow)
  52. {
  53.     MSG        msg;
  54.     UINT        fuErr;
  55.     WORD        winVer;
  56.  
  57.  
  58.     // save the program instance
  59.     hInst = hInstance;
  60.  
  61.     // turn off Windows error "file not found" box.
  62.         // HOWEVER, it doesn't seem to work for BWCC.DLL ...
  63.     fuErr = SetErrorMode ( SEM_NOOPENFILEERRORBOX ) ;
  64.  
  65.     // load the BWCC.DLL
  66.     BWCCGetVersion();
  67.  
  68.     // turn it back on.
  69.     SetErrorMode ( fuErr ) ;
  70.  
  71.     // check version of Windows. At the moment we support 3.1 or higher!
  72.     // this test courtesy of: davidds@microsoft.com (David D'Souza)
  73.     winVer = LOWORD(GetVersion());
  74.     winVer = (((WORD)(LOBYTE(winVer))) << 8)|(WORD)HIBYTE(winVer);
  75.     if (winVer < 0x030A)    // NOTE: Always use a HEX value here!!!
  76.     {     //exit
  77.         char szTemp[256];
  78.         LoadString( hInstance,
  79.                 (UINT)MAKEINTRESOURCE(IDS_BADVERSION),
  80.                 szTemp, sizeof szTemp );
  81.                 BWCCMessageBox (NULL, szTemp, szAppName,
  82.                 MB_ICONSTOP | MB_OK );
  83.         FreeLibrary ( hBWCCDLL );
  84.         return FALSE;
  85.     }
  86.  
  87.     // check command line options
  88.         // debug switch.
  89.     if ( (lstrcmpi(lpszCmdLine,"/d") == 0 ) ||
  90.          (lstrcmpi(lpszCmdLine,"-d") == 0 ) ) iDebugValue = DEBUG;
  91.  
  92.     // check for another instance.
  93.     if ( !hPrevInstance ) {
  94.  
  95.             WNDCLASS        wndclass;
  96.  
  97.             // first run - register class.
  98.         wndclass.style        = CS_HREDRAW | CS_VREDRAW;
  99.             wndclass.lpfnWndProc        = ExitWndProc;       // our WndProc.
  100.         wndclass.cbClsExtra        = 0;
  101.             wndclass.cbWndExtra         = DLGWINDOWEXTRA;    // IMPORTANT!!!
  102.         wndclass.hInstance        = hInstance;
  103.         wndclass.hIcon              = LoadIcon (hInstance, MAKEINTRESOURCE(IDI_EXIT1));
  104.         wndclass.hCursor        = LoadCursor (NULL, IDC_ARROW);
  105.         wndclass.hbrBackground      = (HBRUSH)(COLOR_WINDOW + 1);
  106.         wndclass.lpszMenuName    = MAKEINTRESOURCE(ExitWindowsMenu);
  107.         wndclass.lpszClassName    = szClassName;
  108.  
  109.         if (!RegisterClass (&wndclass))
  110.         return FALSE;
  111.     }
  112.         else {  // we have another instance running.
  113.         HWND hOldWnd;
  114.         char szTemp[256];
  115.  
  116.             // if there is an old window, find it and open it up.
  117.             if ( NULL != (hOldWnd = FindWindow( szClassName, "Exit Windows")) ) {
  118.                 // if its iconic, open it up.
  119.         if( IsIconic(hOldWnd) ) {
  120.                  if ( !OpenIcon ( hOldWnd ) ) {
  121.                            // error. Couldn't open iconized program.
  122.                LoadString( hInstance,
  123.                     (UINT)MAKEINTRESOURCE(IDS_BADOLDICON),
  124.                         szTemp, sizeof szTemp );
  125.                BWCCMessageBox (NULL, szTemp, szAppName,
  126.                     MB_ICONSTOP | MB_OK );
  127.                return FALSE;
  128.              }
  129.                 }
  130.                 // and bring it to the top.
  131.             if ( !BringWindowToTop( hOldWnd ) ) {
  132.                         // error. Couldn't bring window to top.
  133.                 LoadString( hInstance,
  134.                 (UINT)MAKEINTRESOURCE(IDS_BADWINDOWTOP),
  135.                 szTemp, sizeof szTemp );
  136.             BWCCMessageBox (NULL, szTemp, szAppName,
  137.                     MB_ICONSTOP | MB_OK );
  138.             return FALSE;
  139.         }
  140.                 // we found it OK - now bail out.
  141.         return FALSE ;
  142.         }
  143.         else
  144.         {   // error. We have a NULL from FindWindow call. 
  145.             LoadString( hInstance,
  146.                 (UINT)MAKEINTRESOURCE(IDS_BADOLDWINDOW),
  147.                 szTemp, sizeof szTemp );
  148.         BWCCMessageBox (NULL, szTemp, szAppName,
  149.                     MB_ICONSTOP | MB_OK );
  150.         return FALSE;
  151.             }
  152.     }
  153.  
  154.  
  155.     // and tell Windows to that our DialogProc is going to
  156.     // handle the dialog
  157.     hExitWnd = CreateDialog (hInstance, MAKEINTRESOURCE(ExitDialog),
  158.                 0, NULL);
  159.         // check window handle.
  160.         if ( !hExitWnd )
  161.                 return FALSE;
  162.  
  163.     // show it
  164.     ShowWindow (hExitWnd, nCmdShow);
  165.  
  166.         // load accelerators
  167.     hAccel = LoadAccelerators ( hInstance, MAKEINTRESOURCE(ExitAccelerators) );
  168.     if ( ! hAccel )
  169.         return FALSE;
  170.  
  171.         // message loop
  172.     while (GetMessage (&msg, NULL, 0, 0))
  173.         {
  174.          if ( !TranslateAccelerator ( hExitWnd, hAccel, &msg ) )
  175.                  {
  176.                  TranslateMessage (&msg);
  177.               DispatchMessage (&msg);
  178.                  }
  179.         }
  180.  
  181.  
  182.         // and exit.
  183.     return msg.wParam;
  184. }
  185.  
  186.  
  187. // -----------------------------------------------------------------------
  188.  
  189. /*
  190.  * AboutDlgProc - Routine to handle the About dialog window.
  191.  */
  192. #ifdef __BORLANDC__
  193. #pragma argsused
  194. #endif
  195. BOOL FAR PASCAL AboutDlgProc (HWND hDlg, UINT iMessage, UINT wParam, LONG lParam)
  196. {
  197.  
  198.    // set focus to OK button so that the keyboard works.
  199.    SetFocus ( GetDlgItem ( hDlg, IDOK ) );
  200.    // display credits.
  201.    if ((iMessage == WM_COMMAND) && (wParam == IDOK))
  202.       EndDialog(hDlg, 0);    // dismiss dialog if OK
  203.  
  204.    return(0);             // otherwise just sit there
  205. }
  206.  
  207.  
  208.  
  209. // -------------------------------------------------------------------------
  210.  
  211. /*
  212.  * ExitWndProc - Routine to handle main window
  213.  *
  214.  * All messages that we do NOT process, go to the BWCCDefWindowProc
  215.  * which will handle them...
  216.  *
  217.  */
  218.  
  219. LRESULT FAR PASCAL _export ExitWndProc (HWND hDlg, UINT iMessage, UINT wParam, LONG lParam)
  220. {
  221.     static HMENU    hSysMenu;
  222.     FARPROC        lpfnAboutDlgProc;
  223.     static BOOL    fbWriteIni = FALSE ;
  224.         static char     szMenuExitOption[25];
  225.  
  226.  
  227.     switch (iMessage)
  228.     {
  229.  
  230.  
  231.             // create window and fix the system menu
  232.         case WM_CREATE:
  233.         // get the handle to the menu
  234.             hSysMenu = GetSystemMenu(hDlg,FALSE);
  235.                 // add separator line and quick exit.
  236.         AppendMenu(hSysMenu, MF_SEPARATOR, 900, NULL);
  237.                 // default exit mode
  238.         iBootAction = IDD_EXIT;
  239.         // get default exit mode
  240.         if ( IDD_EXIT != ( iBootAction += GetPrivateProfileInt (
  241.                         szSection, szIconExit,
  242.                         0, szIniFile)) )
  243.         {
  244.                     // INI file sanity check.
  245.             if ( iBootAction < IDD_EXIT ||
  246.                  iBootAction > IDD_BOOT ) iBootAction = IDD_EXIT;
  247.                     // we saved the flag (0,1,2) only, *not* the IDD_VALUE.
  248.             // iBootAction += IDD_EXIT;
  249.         }
  250.         // prepare menu strings. The menu item itself will be
  251.         // added during the WM_INIEXIT message, when we are sure
  252.         // that the dialog has been created already.
  253.         switch ( iBootAction )
  254.         {
  255.             case IDD_EXIT:
  256.              wsprintf(szMenuExitOption, "Exit &DOS" );
  257.              break;
  258.  
  259.             case IDD_REST:
  260.              wsprintf(szMenuExitOption, "Restart &Windows" );
  261.              break;
  262.  
  263.                     case IDD_BOOT:
  264.              wsprintf(szMenuExitOption, "Reboot &System" );
  265.              break;
  266.  
  267.         }
  268.  
  269.         // No add the Quick Exit (no questions asked)
  270.         AppendMenu(hSysMenu, MF_STRING, IDM_QUICKEXIT, "&Quick Exit");
  271.                 // check last state, and act accordingly.
  272.         if ( EW_SLOW != ( iQuickExitValue = GetPrivateProfileInt(szSection,
  273.                     szQuickExit, EW_SLOW, szIniFile))) {
  274.             // sanity check.
  275.                     iQuickExitValue = EW_QUICK;
  276.             CheckMenuItem(hSysMenu, IDM_QUICKEXIT, MF_CHECKED);
  277.         }
  278.                 // add AlwaysOnTop
  279.             AppendMenu(hSysMenu, MF_STRING, IDM_ALWAYSONTOP, "Always on &Top");
  280.                 // check last state, and act accordingly.
  281.             if ( GetPrivateProfileInt(szSection,
  282.                       szAlwaysOnTop, 0, szIniFile)) {
  283.             CheckMenuItem(hSysMenu, IDM_ALWAYSONTOP, MF_CHECKED);
  284.             SetWindowPos (hDlg, HWND_TOPMOST, 0, 0, 0, 0,
  285.                                       SWP_NOMOVE | SWP_NOSIZE);
  286.         }
  287.                 //
  288.         // Finally, post ourselves a window (or in this case
  289.         // application) specific message which will initialize
  290.         // our dialog. As we have posted the message, rather
  291.         // than sent it, initialisation will be executed AFTER
  292.         // the dialog window (and all its child windows) has been
  293.         // created.
  294.                 //
  295.         // WM_INITDIALOG is NOT processed since this is a MODELESS
  296.         // dialog main window, and we have our OWN window procedure
  297.                 // which processes dialog messages. Windows sends all
  298.                 // dialog messages to our routine, *and not* to
  299.         // (BWCC)DefDlgProc.
  300.                 //
  301.         PostMessage ( hDlg, WM_INIWINEXIT, 0, 0L );
  302.         return 0;
  303.  
  304.  
  305.  
  306.             // custom message
  307.         case WM_INIWINEXIT:
  308.         // our intialisation of the dialog:
  309.                 // init radio button group (and potentially other stuff)
  310.         SendMessage ( hDlg, WM_COMMAND, iBootAction, 0L );
  311.         return 0;
  312.  
  313.  
  314.  
  315.         case WM_SYSCOMMAND:
  316.         // process messages that come from the system menu.
  317.         // we *would have to* combine it with 0xFFF0 (the four
  318.         // low-order bits of wParam are used internally by
  319.         // Windows) if we were processing SC_* messages, but
  320.         // now we do not have to.
  321.         switch ( wParam )
  322.         {
  323.  
  324.            // if we are iconized, we will get this.
  325.            case IDD_EXIT:
  326.            case IDD_REST:
  327.            case IDD_BOOT:
  328.                SendMessage ( hDlg, WM_COMMAND, wParam, 0L );
  329.                        SendMessage ( hDlg, WM_COMMAND, IDOK, 0L );
  330.                        return 0;
  331.  
  332.  
  333.                    // always on top.
  334.            case IDM_ALWAYSONTOP:
  335.  
  336.                        fbWriteIni = TRUE;
  337.                if ( ( GetMenuState ( hSysMenu, IDM_ALWAYSONTOP,
  338.                         MF_BYCOMMAND) & MF_CHECKED))
  339.                {        // currently topmost, change to notopmost
  340.                 CheckMenuItem ( hSysMenu, IDM_ALWAYSONTOP,
  341.                         MF_UNCHECKED);              
  342.                         SetWindowPos ( hDlg, HWND_NOTOPMOST, 0, 0, 0, 0,                       
  343.                                       SWP_NOMOVE | SWP_NOSIZE);                               
  344.                }
  345.                else
  346.                {        // currently notopmost, change to topmost.                                      
  347.                     CheckMenuItem ( hSysMenu, IDM_ALWAYSONTOP,
  348.                         MF_CHECKED);                
  349.                     SetWindowPos ( hDlg, HWND_TOPMOST, 0, 0, 0, 0,
  350.                         SWP_NOMOVE | SWP_NOSIZE);
  351.                }
  352.                return 0;
  353.  
  354.  
  355.            // Quick exit.
  356.            case IDM_QUICKEXIT:
  357.  
  358.                        fbWriteIni = TRUE;
  359.                if ( ( GetMenuState ( hSysMenu, IDM_QUICKEXIT,
  360.                         MF_BYCOMMAND) & MF_CHECKED))
  361.                {        // currently quickexit, change to slowexit
  362.                      CheckMenuItem ( hSysMenu, IDM_QUICKEXIT,
  363.                         MF_UNCHECKED);
  364.                 iQuickExitValue = EW_SLOW;              
  365.                }
  366.                else
  367.                {        // currently slowexit, change to quickexit.                                      
  368.                     CheckMenuItem ( hSysMenu, IDM_QUICKEXIT,
  369.                         MF_CHECKED);
  370.                 iQuickExitValue = EW_QUICK;
  371.                }
  372.                return 0;
  373.         }
  374.                 // rest goes to BWCCDefWindowProc.
  375.         break;
  376.  
  377.  
  378.  
  379.         // we need to trap WM_SIZE message cases SIZE_MINIMIZED, 
  380.         // SIZE_RESTORED and SIZE_MAXIMIZED so we can modify the
  381.         // system menu. However, the rest of the action goes back
  382.         // to Windows, so we do *not* return a zero.
  383.         // I've tried trapping WM_SYSCOMMAND (SC_MINIMIZE SC_MAXIMIZE)
  384.         // but they work only when invoked from the menu (not when
  385.         // invoked from the 2nd instance of the program!!).
  386.         case WM_SIZE:
  387.            switch ( wParam )
  388.            {
  389.           case SIZE_MINIMIZED:
  390.                AppendMenu(hSysMenu, MF_SEPARATOR, 901, NULL);
  391.                AppendMenu(hSysMenu, MF_STRING, iBootAction, szMenuExitOption);
  392.                break;
  393.  
  394.  
  395.           case SIZE_MAXIMIZED:
  396.           case SIZE_RESTORED:
  397.                DeleteMenu ( hSysMenu, 901, MF_BYCOMMAND );
  398.                DeleteMenu ( hSysMenu, iBootAction, MF_BYCOMMAND );
  399.                        break;
  400.            }
  401.            // rest goes to BWCCDefWindowProc.
  402.                break;
  403.  
  404.  
  405.  
  406.         // add a bit of keyboard control.
  407.         case WM_KEYDOWN:
  408.            switch ( wParam )
  409.            {
  410.             // up and down move radiobuttons.
  411.             case VK_UP:
  412.             case VK_LEFT:
  413.             iBootAction = ((iBootAction - IDD_EXIT + 2) % 3)
  414.                              + IDD_EXIT;
  415.                         SendMessage ( hDlg, WM_COMMAND, iBootAction, 0L );
  416.             return 0;
  417.  
  418.             case VK_DOWN:
  419.             case VK_RIGHT:
  420.             iBootAction = ((iBootAction - IDD_EXIT + 1) % 3)
  421.                              + IDD_EXIT;
  422.             SendMessage ( hDlg, WM_COMMAND, iBootAction, 0L );
  423.             return 0;
  424.  
  425.             // Escape is same as Cancel button
  426.             case VK_ESCAPE:
  427.             SendMessage ( hDlg, WM_COMMAND, IDCANCEL, 0L );
  428.             return 0;
  429.  
  430.             // Return & Space simulate OK.
  431.             case VK_RETURN:
  432.             case VK_SPACE:
  433.             SendMessage ( hDlg, WM_COMMAND, IDOK, 0L );
  434.             return 0;
  435.            }
  436.            // rest goes to BWCCDefWindowProc.
  437.            break;
  438.  
  439.  
  440.  
  441.         // process messages which come from the
  442.         // buttons and the Exit menu.
  443.         case WM_COMMAND:
  444.  
  445.         // set focus to parent window so we can process keyboard.
  446.         SetFocus ( hDlg );
  447.  
  448.         switch (wParam)
  449.         {
  450.             // Button choices.
  451.             case IDOK:
  452.             {
  453.                // Let's get out of this...
  454.                char szTemp[256];
  455.  
  456.  
  457.                // check for quick exit (no questions asked)
  458.                switch ( iQuickExitValue )
  459.                {
  460.                               // slow mover, wants confirmation.
  461.                   case EW_SLOW:
  462.  
  463.                       LoadString ( hInst,
  464.                        (UINT)MAKEINTRESOURCE(IDS_EXITMESSAGE),
  465.                         szTemp, sizeof szTemp );
  466.                       if ( IDOK != BWCCMessageBox ( hDlg,
  467.                            szTemp, szAppName,
  468.                         MB_OKCANCEL |
  469.                         MB_ICONQUESTION ) )
  470.                                          return 0;
  471.  
  472.                                    // else falls thru!!!
  473.  
  474.  
  475.                   // wants to get out ASAP    
  476.                   case EW_QUICK:
  477.  
  478.                                  // only kidding...
  479.                  if (iDebugValue)
  480.                  {
  481.                      LoadString ( hInst,
  482.                            (UINT)MAKEINTRESOURCE(IDS_DEBUGMESSAGE),
  483.                            szTemp, sizeof szTemp );
  484.                      BWCCMessageBox ( hDlg,
  485.                        szTemp, szAppName,
  486.                        MB_OK | MB_ICONASTERISK );
  487.                      return 0;
  488.                  }
  489.  
  490.                  // first destroy the window
  491.                  SendMessage ( hDlg, WM_CLOSE, 0, 0L );
  492.                                  // end then exit.
  493.                  ExitWindows ( lAction [iBootAction -
  494.                             IDD_EXIT], 0);
  495.                            }
  496.             }
  497.             break;
  498.  
  499.  
  500.             // No, we are staying in Windows....
  501.             case IDCANCEL:
  502.             SendMessage( hDlg, WM_CLOSE, 0, 0L );
  503.             return 0; 
  504.  
  505.  
  506.                     // radio buttons (how do we exit Windows)
  507.             case IDD_EXIT:
  508.             case IDD_REST:
  509.             case IDD_BOOT:
  510.             // set the INI write flag
  511.             fbWriteIni = TRUE;
  512.                         // and prepare the menu item string.
  513.             switch ( wParam )
  514.                 {
  515.                   case IDD_EXIT:
  516.                 wsprintf(szMenuExitOption, "Exit to &DOS" );
  517.                 break;
  518.  
  519.                   case IDD_REST:
  520.                 wsprintf(szMenuExitOption, "R&estart Windows" );
  521.                 break;
  522.  
  523.                           case IDD_BOOT:
  524.                 wsprintf(szMenuExitOption, "Reboot &System" );
  525.                 break;
  526.                 }
  527.             // set the appropriate radio button.
  528.             iBootAction = wParam;
  529.             CheckRadioButton(hDlg,IDD_EXIT,IDD_BOOT,iBootAction);
  530.             return 0;
  531.  
  532.  
  533.  
  534.             // give us some credit :-)
  535.             case IDD_ABOUT:
  536.             // obtain a "thunk"
  537.             lpfnAboutDlgProc =
  538.                  MakeProcInstance ((FARPROC)AboutDlgProc,hInst);
  539.             // launch box
  540.             DialogBox (hInst, MAKEINTRESOURCE(AboutDialog),
  541.                    hDlg, (DLGPROC)lpfnAboutDlgProc);
  542.                         // free thunk.
  543.             FreeProcInstance (lpfnAboutDlgProc);
  544.             return 0;
  545.  
  546.  
  547.  
  548.             // Menu choices.
  549.             case IDM_EXIT:
  550.             SendMessage ( hDlg, WM_COMMAND, IDD_EXIT, 1L );
  551.             SendMessage ( hDlg, WM_COMMAND, IDOK, 1L );
  552.             return 0;
  553.  
  554.             case IDM_REST:
  555.             SendMessage ( hDlg, WM_COMMAND, IDD_REST, 1L );
  556.             SendMessage ( hDlg, WM_COMMAND, IDOK, 1L );
  557.             return 0;
  558.  
  559.             case IDM_BOOT:
  560.                         SendMessage ( hDlg, WM_COMMAND, IDD_BOOT, 1L );
  561.             SendMessage ( hDlg, WM_COMMAND, IDOK, 1L );
  562.             return 0;
  563.  
  564.             case IDM_ABOUT:
  565.             SendMessage ( hDlg, WM_COMMAND, IDD_ABOUT, 1L );
  566.                         return 0;
  567.  
  568.         }
  569.         // rest goes to BWCCDefWindowProc.
  570.         break;
  571.  
  572.  
  573.         case WM_DESTROY:
  574.         // flush things to disk if needed.
  575.         if ( fbWriteIni ) {
  576.            // make block to allocate szTemp.
  577.                    BOOL bfChecked;
  578.            char szTemp[5];
  579.            int iExit;
  580.  
  581.            // Exit Windows mode.
  582.            iExit = iBootAction - IDD_EXIT;
  583.            wsprintf(szTemp,"%d",iExit);
  584.            WritePrivateProfileString (szSection,
  585.                              szIconExit,
  586.                           szTemp,
  587.                           szIniFile );
  588.            // AlwaysOnTop.
  589.                  WritePrivateProfileString (szSection, szAlwaysOnTop,
  590.                  ( GetMenuState(hSysMenu, IDM_ALWAYSONTOP,
  591.                     MF_BYCOMMAND) & MF_CHECKED ) ?
  592.                              "1" : "0", szIniFile);
  593.  
  594.  
  595.            // QuickExit.
  596.            bfChecked = GetMenuState(hSysMenu, IDM_QUICKEXIT,MF_BYCOMMAND);
  597.            iExit = ( bfChecked & MF_CHECKED ) ? EW_QUICK : EW_SLOW ;
  598.            wsprintf(szTemp,"%d",iExit);
  599.            WritePrivateProfileString (szSection,
  600.                               szQuickExit,
  601.                                                szTemp,
  602.                            szIniFile );
  603.  
  604.                    // this will flush buffers to disk NOW.
  605.            WritePrivateProfileString ( NULL, NULL, NULL, szIniFile );
  606.                 }
  607.         // bye...
  608.         PostQuitMessage ( 0 ) ;
  609.                 return 0;
  610.  
  611.     }
  612.  
  613.         // handle all other messages.
  614.     return BWCCDefWindowProc( hDlg, iMessage, wParam, lParam);
  615.  
  616. }
  617.