home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / SYSINF.ZIP / SYSINFO.C < prev    next >
C/C++ Source or Header  |  1993-01-01  |  36KB  |  818 lines

  1. /****************************************************
  2. **                                                 **
  3. ** Program: Sysinfo.c                              **
  4. ** Author : Gene Backlin                           **
  5. **                                                 **
  6. ** Address: CompuServe ID 70401,1574               **
  7. **                                                 **
  8. ** Purpose: To give the User as well as the        **
  9. **          Programmer new to OS/2's Presentation  **
  10. **          Manager interface, a generic shell, to **
  11. **          see how the pieces are fit together.   **
  12. **                                                 **
  13. ** Written: 12/25/92                               **
  14. ** Revised: 12/30/92                               **
  15. **    Version 1.00 - 12/25/92                      **
  16. **       Original Version                          **
  17. **    Version 1.10 - 12/30/92                      **
  18. **       Added Notebook Control                    **
  19. **                                                 **
  20. ****************************************************/
  21. #define INCL_32
  22.  
  23. #define INCL_WIN
  24. #define INCL_GPI
  25.  
  26. #define INCL_WINHELP                            // Include IPF Header File
  27. #define INCL_VIO
  28.  
  29. #define INCL_DOS
  30. #define INCL_DOSFILEMGR
  31. #define INCL_DOSMEMMGR
  32. #define INCL_DONMPIPES
  33. #define INCL_ERRORS
  34.  
  35. #define MAX    24
  36.  
  37. #include <os2.h>
  38. #include <stdio.h>
  39. #include <stdlib.h>
  40. #include <bsedos.h>
  41.  
  42. #include "sysinfo.h"
  43. #include "notebook.h"
  44.  
  45. struct _sys_settings
  46. {
  47.   ULONG ulMaxPath;                         
  48.   ULONG ulMaxTextSessions;             
  49.   ULONG ulMaxPMSessions;                 
  50.   ULONG ulMaxVDMSessions;                 
  51.   ULONG ulBootDrive;                     
  52.   ULONG ulDynamicPriorityVariation; 
  53.   ULONG ulMaxWait_sec;                     
  54.   ULONG ulMinTimeSlice_ms;             
  55.   ULONG ulMaxTimeSlice_ms;             
  56.   ULONG ulPageSize_by;                     
  57.   ULONG ulVersionMajor;                 
  58.   ULONG ulVersionMinor;                 
  59.   ULONG ulVersionRevision;             
  60.   ULONG ulMilliSecCounter;            
  61.   ULONG ulLowOrdTime;                     
  62.   ULONG ulHighOrdTime;                     
  63.   ULONG ulTotalPhysicalMemoryPages; 
  64.   ULONG ulTotalResidentMemoryPages; 
  65.   ULONG ulTotalAvailableMemoryPages;
  66.   ULONG ulTotalMaxPrivateMemory_by;
  67.   ULONG ulTotalMaxSharedMemory_by;
  68.   ULONG ulTimerInterval;
  69.   ULONG ulMaxComponentLength_by;     
  70. } sys_settings, *psys_settings;
  71.  
  72. ULONG   StartIndex;            /* Ordinal of 1st variable to return     */
  73. ULONG   LastIndex;             /* Ordinal of last variable to return     */
  74. ULONG   DataBuf[MAX];       /* System information (returned)         */
  75. ULONG   DataBufLen;            /* Data buffer size                             */
  76. APIRET  rc;                    /* Return code                                 */
  77.  
  78. CHAR szErrMsg  [79] = "\0";
  79. CHAR szErrTitle[40] = "\0";
  80.  
  81. HWND hwndFrame;                                 // PM Handle to the Frame
  82.  
  83. /****************************************************
  84. *                                                   *
  85. *  Function Prototypes                              *
  86. *                                                   *
  87. ****************************************************/
  88. MRESULT EXPENTRY ClientWndProc   (HWND, ULONG, MPARAM, MPARAM);
  89. MRESULT EXPENTRY AboutDlgProc    (HWND, ULONG, MPARAM, MPARAM);
  90. MRESULT EXPENTRY CenterDlg       (HWND hwnd);
  91. INT     EXPENTRY get_system_info (HWND);
  92. INT     EXPENTRY system_info_out (HWND);
  93.  
  94. BOOL    AddNotebookPages (HWND, PNBC);
  95. FNWP    NotebookDlgProc;
  96.  
  97. /****************************************************
  98. *                                                   *
  99. *  Required IPF Structure Declarations              *
  100. *                                                   *
  101. ****************************************************/
  102. HELPINIT    hmiHelpData;                        // Help Initialization Structure
  103. HWND        hwndHelpInstance;                   // Handle to the Help Window
  104.  
  105. /* */
  106. /****************************************************
  107. *                                                   *
  108. *  Main Function                                    *
  109. *                                                   *
  110. ****************************************************/
  111. INT main(INT argc, CHAR *argv, CHAR *envp)
  112. {
  113.    HAB     hab;                                 // Handle to Application  
  114.    HMQ     hmq;                                 // Hold the Application's Message Queue
  115.    QMSG    qmsg;                                // The actual Queue Message             
  116.  
  117.    HWND    hwndClient;                          // PM Window Handles
  118.    HWND    hwndMenu;                            // Menu Handle
  119.    HWND    hwndTemp;                            // Temporary Menu Handle
  120.  
  121.    SWCNTRL SwData;                              // Switch control data block
  122.    HSWITCH hSwitch;                             // Switch entry handle
  123.  
  124.    ULONG flFrameFlags =                         // Set the Frame-window creation Flags
  125.       FCF_MENU          |                       // Application Menu
  126.       FCF_TITLEBAR      |                       // Application Title
  127.       FCF_SIZEBORDER    |                       // Application Size Border
  128.       FCF_MINMAX        |                       // Minimize and Maximum Buttons
  129.       FCF_SYSMENU       |                       // Application System Menu
  130.       FCF_SHELLPOSITION    |                       // System default size and position
  131.       FCF_ICON          |                       // System default size and position
  132.       FCF_TASKLIST;                             // Add name to TaskList
  133.  
  134.    hab = WinInitialize(0);                      // Register the Application
  135.    hmq = WinCreateMsgQueue(hab, 0);             // Create the Message Queue
  136.  
  137.    if (!WinRegisterClass(                       // Register the window class
  138.       hab,                                      // Handle to application
  139.       CLIENT_CLASS,                             // Name of the Class
  140.       ClientWndProc,                               // Window procedure name
  141.       CS_SIZEREDRAW,                               // Window style
  142.       0))                                       // Extra window words
  143.          return (FALSE);                        // Terminate if Unsuccessful
  144.  
  145. /****************************************************
  146. *                                                   *
  147. *  IPF Initialization Structure                     *
  148. *                                                   *
  149. ****************************************************/
  150.    hmiHelpData.cb                      = sizeof(HELPINIT);    // size of initialization structure
  151.    hmiHelpData.ulReturnCode            = 0;        // store HM return code from init
  152.    hmiHelpData.pszTutorialName         = 0;        // no tutorial program
  153.    hmiHelpData.phtHelpTable            = (PVOID)
  154.                   (0xffff0000 | MAIN_HELPTABLE);   // help table defined in RC file
  155.    hmiHelpData.hmodAccelActionBarModule= 0;
  156.    hmiHelpData.idAccelTable            = 0;
  157.    hmiHelpData.idActionBar             = 0;
  158.    hmiHelpData.pszHelpWindowTitle      = HELPTITLE;
  159.    hmiHelpData.hmodHelpTableModule     = 0;        // Help Table not in a DLL
  160.    hmiHelpData.fShowPanelId            = 0;        // Help Panels ID is not displayed
  161.    hmiHelpData.pszHelpLibraryName      = HELPFILE; // Library with help panels
  162.  
  163. /****************************************************
  164. *                                                   *
  165. *  Create Instance of IPF                           *
  166. *                                                   *
  167. ****************************************************/
  168.    hwndHelpInstance =                            // Pass Anchor Block handle and address 
  169.       WinCreateHelpInstance(hab, &hmiHelpData);  // of IPF initialization structure
  170.  
  171.    if(!hwndHelpInstance)
  172.       {
  173.       WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
  174.                    (PSZ) "Help Not Available",
  175.                    (PSZ) "Help Creation Error",
  176.                    1,
  177.                    MB_OK | MB_APPLMODAL | MB_MOVEABLE);
  178.       }
  179.    else
  180.       {
  181.       if(hmiHelpData.ulReturnCode)
  182.          {
  183.          WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
  184.                       (PSZ) "Help NotAvailable",
  185.                       (PSZ) "Help Creation Error",
  186.                       1,
  187.                       MB_OK | MB_APPLMODAL | MB_MOVEABLE);
  188.          WinDestroyHelpInstance(hwndHelpInstance);
  189.          }
  190.       }
  191.  
  192. /****************************************************
  193. *                                                   *
  194. *  Create a Top-Level frame window with a client    *
  195. *  window that belongs to the window class          *
  196. *  CLIENT_CLASS. (see sysinfo.h)                    *
  197. *                                                   *
  198. ****************************************************/
  199.    hwndFrame = WinCreateStdWindow(              // Create the Frame Window
  200.                       HWND_DESKTOP,                // Parent is the Desktop
  201.                       0L,                       // Don't make frame window visible
  202.                       &flFrameFlags,            // Frame Controls
  203.                       CLIENT_CLASS,                // Window class for client
  204.                       TITLE,                    // Window Title
  205.                       0L,                       // Don't make client window visible
  206.                       0,                        // Resources in application model
  207.                       ID_MENU_RESOURCE,         // Resource identifier
  208.                       &hwndClient);                // Pointer to client window handle
  209.    if (!hwndFrame)
  210.       return (FALSE);
  211.  
  212.    WinSetWindowPos(
  213.       hwndFrame,                                // Shows and activates frame
  214.       HWND_TOP,                                 // Put the window on top
  215.       55,                                       // Positon x
  216.       350,                                      // Positon y
  217.       525,                                      // New width
  218.       75,                                       // New height
  219.       SWP_SIZE      |                           // Change the size
  220.       SWP_MOVE      |                           // Move the window
  221.       SWP_ACTIVATE  |                           // Make it the active window
  222.       SWP_SHOW                                  // Make it visible
  223.       );
  224.  
  225.    hwndMenu =
  226.       WinWindowFromID( hwndFrame, FID_MENU);    // Get the Menu handle
  227.  
  228.    SwData.hwnd          = hwndFrame;            // Set frame Window handle
  229.    SwData.hwndIcon      = 0;                    // Use the default Icon
  230.    SwData.hprog;                                // Use default program handle
  231.    SwData.idProcess     = 0;                    // Use current process id
  232.    SwData.idSession     = 0;                    // Use current session id
  233.    SwData.uchVisibility    = SWL_VISIBLE;          // Make Visible
  234.    SwData.fbJump        = SWL_JUMPABLE;         // Make Jumpable via Alt+Esc
  235.    SwData.szSwtitle[0]  = '\0';                 // Use default Title Test
  236.  
  237.    hSwitch = WinAddSwitchEntry(&SwData);        // Add task manager entry
  238.  
  239. /****************************************************
  240. *                                                   *
  241. *  Associate Instance of IPF                        *
  242. *                                                   *
  243. ****************************************************/
  244.    if(hwndHelpInstance)
  245.       WinAssociateHelpInstance(hwndHelpInstance, hwndFrame);
  246.  
  247. /****************************************************
  248. *                                                   *
  249. *  Start the main message loop. Get Messages from   *
  250. *  the queue and dispatch them to the appropriate   *
  251. *  windows.                                         *
  252. *                                                   *
  253. ****************************************************/
  254.    while(WinGetMsg(hab, &qmsg, 0, 0, 0))        // Loop until WM_QUIT
  255.       WinDispatchMsg(hab, &qmsg);
  256.  
  257. /****************************************************
  258. *                                                   *
  259. *  Main Loop has terminated. Destroy all windows and*
  260. *  the message queue; then terminate the application*
  261. *                                                   *
  262. ****************************************************/
  263.    if(hwndHelpInstance)
  264.       WinDestroyHelpInstance(hwndHelpInstance);    // Destroy Help Instance
  265.  
  266.    WinDestroyWindow(hwndFrame);                 // Destroy main window
  267.    WinDestroyMsgQueue(hmq);                     // Destroy message queue
  268.    WinTerminate(hab);                           // Deregister application
  269.  
  270.    return 0;
  271. }
  272.  
  273. /* */
  274. /****************************************************
  275. *                                                   *
  276. *  Client Window Procedure                          *
  277. *                                                   *
  278. ****************************************************/
  279. MRESULT EXPENTRY ClientWndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  280. {
  281.    HWND    hwndTemp;                            // Temporary Menu Handle
  282.    RECTL   rcl;                                 // Window rectangle
  283.    HPS     hps;                                 // Handle to the Presentation space
  284.    UCHAR   szMsg[40];                           // Standared Text Message
  285.    UCHAR   szTitle[20];                         // Title...
  286.    ULONG   rc;                                  // Status return code
  287.    static  NBC nbControl;                       // Notebook Control parameters
  288.  
  289.    switch(msg)
  290.       {
  291.       case WM_CREATE:
  292.          WinSendMsg(                            // is just the
  293.               hwnd,                             // About Box
  294.               WM_COMMAND,                       // Credit
  295.               (MPARAM) IDM_HEL_ABOUT,             // Display.
  296.               0L);
  297.          break;
  298.       
  299.       case WM_ERASEBACKGROUND:
  300.         return (MRESULT)(TRUE);
  301.       
  302.       case WM_CHAR:
  303.         return (MRESULT)(TRUE);
  304.       
  305.       case WM_PAINT:
  306.         hps = WinBeginPaint(hwnd, 0, &rcl);
  307.         WinEndPaint(hps);
  308.         break;
  309.       
  310.       case WM_COMMAND:
  311.         switch (SHORT1FROMMP(mp1))
  312.           {
  313.           case IDM_DIS_NOTEBOOK:
  314.             WinCreateStdNotebook(hwnd,           // Application Window Handle
  315.                               &nbControl,        // Notebook Control Structure
  316.                               160,               // xLeft Position
  317.                               15,                // yBottom Position
  318.                               350,               // xRight Position
  319.                               325,               // yTop Position
  320.                               ID_NOTEBOOK,       // Notebook Window ID
  321.                               HWND_DESKTOP,      // Parent Window Handle
  322.                               HWND_DESKTOP       // Owner Window Handle
  323.                               );
  324.             AddNotebookPages(hwnd, &nbControl);  // Add pages to the Notebook Control
  325.             WinDisplayNotebook(hwnd,&nbControl); // Display the Notebook Control
  326.             return 0;
  327.       
  328.           case IDM_DIS_NOTEBOOK_EXIT:
  329.             WinDestroyNotebook(hwnd, &nbControl);
  330.             return 0;
  331.  
  332.           case IDM_HEL_ABOUT:                    // Program Credits
  333.             rc = WinDlgBox(
  334.                     HWND_DESKTOP,                // Desktop is parent
  335.                     hwnd,                        // Current window is owner
  336.                     AboutDlgProc,                // Entry point of dialog proc.
  337.                     0,                           // Resource is in EXE
  338.                     IDD_ABOUTBOX,                // Dialog resource identifier
  339.                     (PVOID)NULL);                // Pointer to initialization dat
  340.             return 0;
  341.       
  342.           case IDM_EXIT:
  343.             WinSendMsg(hwnd, WM_CLOSE, 0, 0);    // Exit the Program
  344.             return 0;
  345.       
  346.           case IDM_HELP_FOR_HELP:
  347.             if(hwndHelpInstance)
  348.               WinSendMsg(hwndHelpInstance, HM_DISPLAY_HELP, 0L, 0L);
  349.             break;
  350.       
  351.           default:
  352.             return WinDefWindowProc(hwnd, msg, mp1, mp2);
  353.           }
  354.         break;
  355.       
  356.       case HM_ERROR:
  357.         if((hwndHelpInstance && (ULONG) mp1) == HMERR_NO_MEMORY)
  358.           {
  359.           WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
  360.                        (PSZ) "Help Terminated Due to Error",
  361.                        (PSZ) "Help Error",
  362.                        1,
  363.                        MB_OK | MB_APPLMODAL | MB_MOVEABLE);
  364.             WinDestroyHelpInstance(hwndHelpInstance);
  365.           }
  366.         else
  367.           {
  368.             WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
  369.                        (PSZ) "Help Error Occurred",
  370.                        (PSZ) "Help Error",
  371.                        1,
  372.                        MB_OK | MB_APPLMODAL | MB_MOVEABLE);
  373.           }
  374.         break;
  375.       
  376.       case WM_CLOSE:
  377.         /*
  378.          * This is the place to put your termination routines
  379.          */
  380.       
  381.         WinPostMsg( hwnd, WM_QUIT, 0L, 0L );    // Cause termination
  382.         break;
  383.       
  384.       default:
  385.         return WinDefWindowProc(hwnd, msg, mp1, mp2); 
  386.       }
  387.   return (MRESULT)FALSE;
  388. }
  389.  
  390. /* */
  391. /****************************************************
  392. *                                                   *
  393. *  About Window Procedure                           *
  394. *                                                   *
  395. ****************************************************/
  396. MRESULT EXPENTRY AboutDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
  397. {
  398.   switch(msg)
  399.     {
  400.     case WM_INITDLG:
  401.       CenterDlg(hwnd);
  402.       return 0;
  403.  
  404.     case WM_COMMAND:
  405.       switch( SHORT1FROMMP( mp1 ) )             // Extract the command value
  406.         {
  407.         case DID_OK:
  408.           WinDismissDlg( hwnd, DID_OK );
  409.         break;
  410.  
  411.         case DID_CANCEL:
  412.           WinDismissDlg( hwnd, DID_CANCEL );
  413.         break;
  414.         }
  415.  
  416.     default:
  417.       return(WinDefDlgProc(hwnd, msg, mp1, mp2));
  418.       break;
  419.     }
  420.   return(MPVOID);
  421. }   /* AboutDlgProc() */
  422.  
  423. /* */
  424. /****************************************************
  425. *                                                   *
  426. *  Center Dialog Box Procedure                      *
  427. *                                                   *
  428. ****************************************************/
  429. MRESULT EXPENTRY CenterDlg(HWND hwnd)
  430. {
  431.    RECTL rclScreen;
  432.    RECTL rclDialog;
  433.    LONG  sWidth, sHeight, sBLCx, sBLCy;
  434.    
  435.    WinQueryWindowRect(HWND_DESKTOP, &rclScreen);
  436.    WinQueryWindowRect(hwnd, &rclDialog);
  437.    
  438.    sWidth  = (LONG) (rclDialog.xRight - rclDialog.xLeft);
  439.    sHeight = (LONG) (rclDialog.yTop   - rclDialog.yBottom);
  440.    sBLCx   = ((LONG) rclScreen.xRight - sWidth)  / 2;
  441.    sBLCy   = ((LONG) rclScreen.yTop   - sHeight) / 2;
  442.    
  443.    WinSetWindowPos(
  444.       hwnd,                                    // Activates frame
  445.       HWND_TOP,                                // Put the window on top
  446.       sBLCx,                                   // Positon x
  447.       sBLCy,                                   // Positon y
  448.       0,                                       // New width
  449.       0,                                       // New height
  450.       SWP_MOVE);                               // Move the window
  451.                                                
  452.    return 0;                                   
  453. }
  454.  
  455. /* */
  456. /*******************************************************
  457. **                                                    **
  458. **       AddNotebookPages                             **
  459. **                                                    **
  460. *******************************************************/
  461. BOOL AddNotebookPages (HWND hwnd, PNBC nbControl)
  462. {
  463.    nbControl->nbtDimensions.lMinorTabWidth = 90;
  464.  
  465. /********************************************
  466. *       Setup Title Page                   **
  467. ********************************************/
  468.    nbControl->sPageFlags                   = NB_DEFAULT_MAJOR_FLAGS;
  469.    nbControl->nbtDimensions.szMajorTabText = (PSZ)"System";
  470.    nbControl->szStatusLineText             = (PSZ)"Current Operating System";
  471.    nbControl->pfnwpDlgProc                 = NotebookDlgProc;
  472.    nbControl->ulDlgId                      = IDD_NB_PAGE1;
  473.    
  474.    WinInsertNotebookPage(hwnd,
  475.                       nbControl,                // Notebook Control 
  476.                       TRUE,                     // Are there Major Tabs on Page ?
  477.                       FALSE,                    // Are there Minor Tabs on Page ?
  478.                       TRUE,                     // Is there a Dialog Box associated with Page ?
  479.                       TRUE                      // Is there Status Line Text ?
  480.                       );
  481.  
  482. /********************************************
  483. *       Setup Page 1A                      **
  484. ********************************************/
  485.    nbControl->sPageFlags                   = NB_DEFAULT_MINOR_FLAGS;
  486.    nbControl->nbtDimensions.szMinorTabText = (PSZ)"Values";
  487.    nbControl->szStatusLineText             = (PSZ)"Current Maximum Settings";
  488.    nbControl->pfnwpDlgProc                 = NotebookDlgProc;
  489.    nbControl->ulDlgId                      = IDD_NB_PAGE1A;
  490.    
  491.    WinInsertNotebookPage(hwnd,
  492.                       nbControl,                // Notebook Control 
  493.                       FALSE,                    // Are there Major Tabs on Page ?
  494.                       TRUE,                     // Are there Minor Tabs on Page ?
  495.                       TRUE,                     // Is there a Dialog Box associated with Page ?
  496.                       TRUE                      // Is there Status Line Text ?
  497.                       );
  498.  
  499. /********************************************
  500. *       Setup Page 1B                      **
  501. ********************************************/
  502.    nbControl->sPageFlags                   = NB_DEFAULT_MINOR_FLAGS;
  503.    nbControl->nbtDimensions.szMinorTabText = (PSZ)"Time";
  504.    nbControl->szStatusLineText             = (PSZ)"Current Settings";
  505.    nbControl->pfnwpDlgProc                 = NotebookDlgProc;
  506.    nbControl->ulDlgId                      = IDD_NB_PAGE1B;
  507.    
  508.    WinInsertNotebookPage(hwnd,
  509.                       nbControl,                // Notebook Control 
  510.                       FALSE,                    // Are there Major Tabs on Page ?
  511.                       TRUE,                     // Are there Minor Tabs on Page ?
  512.                       TRUE,                     // Is there a Dialog Box associated with Page ?
  513.                       TRUE                      // Is there Status Line Text ?
  514.                       );
  515.  
  516. /********************************************
  517. *       Setup Page 2                       **
  518. ********************************************/
  519.    nbControl->sPageFlags                   = NB_DEFAULT_MAJOR_FLAGS;
  520.    nbControl->nbtDimensions.szMajorTabText = (PSZ)"Memory";
  521.    nbControl->szStatusLineText             = (PSZ)"Current Operating System";
  522.    nbControl->pfnwpDlgProc                 = NotebookDlgProc;
  523.    nbControl->ulDlgId                      = IDD_NB_PAGE2;
  524.    
  525.    WinInsertNotebookPage(hwnd,
  526.                       nbControl,                // Notebook Control 
  527.                       TRUE,                     // Are there Major Tabs on Page ?
  528.                       FALSE,                    // Are there Minor Tabs on Page ?
  529.                       TRUE,                     // Is there a Dialog Box associated with Page ?
  530.                       TRUE                      // Is there Status Line Text ?
  531.                       );
  532.  
  533. /********************************************
  534. *       Setup Page 2A                      **
  535. ********************************************/
  536.    nbControl->sPageFlags                   = NB_DEFAULT_MINOR_FLAGS;
  537.    nbControl->nbtDimensions.szMinorTabText = (PSZ)"Values";
  538.    nbControl->szStatusLineText             = (PSZ)"Current Maximum Settings";
  539.    nbControl->pfnwpDlgProc                 = NotebookDlgProc;
  540.    nbControl->ulDlgId                      = IDD_NB_PAGE2A;
  541.    
  542.    WinInsertNotebookPage(hwnd,
  543.                       nbControl,                // Notebook Control 
  544.                       FALSE,                    // Are there Major Tabs on Page ?
  545.                       TRUE,                     // Are there Minor Tabs on Page ?
  546.                       TRUE,                     // Is there a Dialog Box associated with Page ?
  547.                       TRUE                      // Is there Status Line Text ?
  548.                       );
  549.  
  550. /********************************************
  551. *       Setup Page 3                       **
  552. ********************************************/
  553.    nbControl->sPageFlags                   = NB_DEFAULT_MAJOR_FLAGS;
  554.    nbControl->nbtDimensions.szMajorTabText = (PSZ)"Timers";
  555.    nbControl->szStatusLineText             = (PSZ)"Current System Settings";
  556.    nbControl->pfnwpDlgProc                 = NotebookDlgProc;
  557.    nbControl->ulDlgId                      = IDD_NB_PAGE3;
  558.    
  559.    WinInsertNotebookPage(hwnd,
  560.                       nbControl,                // Notebook Control 
  561.                       TRUE,                     // Are there Major Tabs on Page ?
  562.                       FALSE,                    // Are there Minor Tabs on Page ?
  563.                       TRUE,                     // Is there a Dialog Box associated with Page ?
  564.                       TRUE                      // Is there Status Line Text ?
  565.                       );
  566.  
  567. /********************************************
  568. *       Setup Page 3A                      **
  569. ********************************************/
  570.    nbControl->sPageFlags                   = NB_DEFAULT_MINOR_FLAGS;
  571.    nbControl->nbtDimensions.szMinorTabText = (PSZ)"Values";
  572.    nbControl->szStatusLineText             = (PSZ)"Current System Settings";
  573.    nbControl->pfnwpDlgProc                 = NotebookDlgProc;
  574.    nbControl->ulDlgId                      = IDD_NB_PAGE3A;
  575.    
  576.    WinInsertNotebookPage(hwnd,
  577.                       nbControl,                // Notebook Control 
  578.                       FALSE,                    // Are there Major Tabs on Page ?
  579.                       TRUE,                     // Are there Minor Tabs on Page ?
  580.                       TRUE,                     // Is there a Dialog Box associated with Page ?
  581.                       TRUE                      // Is there Status Line Text ?
  582.                       );
  583.  
  584. /********************************************
  585. *       Get SysInfo Help                   **
  586. ********************************************/
  587.    nbControl->sPageFlags                   = NB_DEFAULT_MAJOR_FLAGS;
  588.    nbControl->nbtDimensions.szMajorTabText = (PSZ)"Help";
  589.    nbControl->szStatusLineText             = (PSZ)"Use F1 for Detailed Help";
  590.    nbControl->pfnwpDlgProc                 = NotebookDlgProc;
  591.    nbControl->ulDlgId                      = IDD_NB_PAGE_HELP;
  592.    
  593.    WinInsertNotebookPage(hwnd,
  594.                       nbControl,                // Notebook Control 
  595.                       TRUE,                     // Are there Major Tabs on Page ?
  596.                       FALSE,                    // Are there Minor Tabs on Page ?
  597.                       TRUE,                     // Is there a Dialog Box associated with Page ?
  598.                       TRUE                      // Is there Status Line Text ?
  599.                       );
  600.  
  601. /********************************************
  602. *       Close the Notebook                 **
  603. ********************************************/
  604.    nbControl->sPageFlags                   = NB_DEFAULT_MAJOR_FLAGS;
  605.    nbControl->nbtDimensions.szMajorTabText = (PSZ)"Exit";
  606.    nbControl->szStatusLineText             = (PSZ)"Press Exit to Close Notebook";
  607.    nbControl->pfnwpDlgProc                 = NotebookDlgProc;
  608.    nbControl->ulDlgId                      = IDD_NB_EXIT_PAGE;
  609.    
  610.    WinInsertNotebookPage(hwnd,
  611.                       nbControl,                // Notebook Control 
  612.                       TRUE,                     // Are there Major Tabs on Page ?
  613.                       FALSE,                    // Are there Minor Tabs on Page ?
  614.                       TRUE,                     // Is there a Dialog Box associated with Page ?
  615.                       TRUE                      // Is there Status Line Text ?
  616.                       );
  617.  
  618.    return (TRUE);
  619. }
  620.  
  621. /* */
  622. /*******************************************************
  623. **                                                    **
  624. **       Notebook Dialog Box Procedure                **
  625. **                                                    **
  626. *******************************************************/
  627. MRESULT EXPENTRY NotebookDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
  628. {
  629.    CHAR  szTemp[40];
  630.    CHAR  szCurrentTitle[40];
  631.  
  632.    switch(msg)
  633.      {
  634.      case WM_INITDLG:
  635.        get_system_info(hwnd);
  636.  
  637.        sprintf(szTemp, "%lu.%02lu.%lu",sys_settings.ulVersionMajor/10,
  638.                                        sys_settings.ulVersionMinor,
  639.                                        sys_settings.ulVersionRevision);
  640.        strcpy(szCurrentTitle, " Version ");
  641.        strcat(szCurrentTitle, szTemp);
  642.  
  643.        WinSetDlgItemText(hwnd, IDD_VERSION, szCurrentTitle);
  644.  
  645.        return 0;
  646.    
  647.      case WM_COMMAND:
  648.        switch( SHORT1FROMMP( mp1 ) )             // Extract the command value
  649.          {
  650.          case IDD_NB_NOTEBOOK_CLOSE:
  651.           WinSendMsg(                         
  652.               hwndFrame,                           
  653.               WM_COMMAND,                     
  654.               (MPARAM) IDM_DIS_NOTEBOOK_EXIT, 
  655.               0L);
  656.            break;
  657.    
  658.          case DID_OK:
  659.             break;
  660.    
  661.          case DID_CANCEL:
  662.             break;
  663.          }
  664.    
  665.      default:
  666.        return(WinDefDlgProc(hwnd, msg, mp1, mp2));
  667.        break;
  668.      }
  669.    return(WinDefDlgProc(hwnd, msg, mp1, mp2));
  670. }   /* NotebookDlgProc() */
  671.  
  672. /***************************************/
  673. /*                                     */
  674. /*       Get System Information        */
  675. /*                                     */
  676. /***************************************/
  677. INT EXPENTRY get_system_info(HWND hwnd)
  678. {
  679.   StartIndex = QSV_MAX_PATH_LENGTH;    /* In this example we will ask for the */
  680.   LastIndex  = QSV_MAX_COMP_LENGTH;    /*   maximum number of Text, PM and    */
  681.                                              /*   DOS sessions on the local system  */
  682.  
  683.   DataBufLen = sizeof(DataBuf);            /* Size of the supplied data buffer     */
  684.  
  685.   rc = DosQuerySysInfo((ULONG)StartIndex, (ULONG)LastIndex,
  686.                            (PVOID)DataBuf, (ULONG)DataBufLen);
  687.                       /* On successful return, the three    */
  688.                       /*   requested doubleword values will */
  689.                       /*   be contained within the supplied */
  690.                       /*   data buffer                      */
  691.   if (rc != 0)
  692.     {
  693.     sprintf(szErrMsg,"DosQuerySysInfo error\n Return Code = %ld", rc);
  694.     rc = WinMessageBox(HWND_DESKTOP,
  695.                               hwnd,    
  696.                             (char *)szErrMsg,    
  697.                             (char *)szErrTitle,    
  698.                             WinQueryWindowUShort(hwnd, QWS_ID), /* Window Id        */
  699.                             MB_OK         |    
  700.                             MB_ERROR);    
  701.                               
  702.     }
  703.   else
  704.     {                                                       
  705.     sys_settings.ulMaxPath                   = DataBuf[QSV_MAX_PATH_LENGTH - 1];
  706.     sys_settings.ulMaxTextSessions           = DataBuf[QSV_MAX_TEXT_SESSIONS - 1];
  707.     sys_settings.ulMaxPMSessions             = DataBuf[QSV_MAX_PM_SESSIONS - 1];
  708.     sys_settings.ulMaxVDMSessions            = DataBuf[QSV_MAX_VDM_SESSIONS  - 1];
  709.     sys_settings.ulBootDrive                 = DataBuf[QSV_BOOT_DRIVE - 1];
  710.     sys_settings.ulDynamicPriorityVariation  = DataBuf[QSV_DYN_PRI_VARIATION - 1];
  711.     sys_settings.ulMaxWait_sec               = DataBuf[QSV_MAX_WAIT - 1];
  712.     sys_settings.ulMinTimeSlice_ms           = DataBuf[QSV_MIN_SLICE - 1];
  713.     sys_settings.ulMaxTimeSlice_ms           = DataBuf[QSV_MAX_SLICE - 1];
  714.     sys_settings.ulPageSize_by               = DataBuf[QSV_PAGE_SIZE - 1];
  715.     sys_settings.ulVersionMajor              = DataBuf[QSV_VERSION_MAJOR - 1];
  716.     sys_settings.ulVersionMinor              = DataBuf[QSV_VERSION_MINOR - 1];
  717.     sys_settings.ulVersionRevision           = DataBuf[QSV_VERSION_REVISION - 1];
  718.     sys_settings.ulMilliSecCounter           = DataBuf[QSV_MS_COUNT - 1];
  719.     sys_settings.ulLowOrdTime                = DataBuf[QSV_TIME_LOW - 1];
  720.     sys_settings.ulHighOrdTime               = DataBuf[QSV_TIME_HIGH - 1];
  721.     sys_settings.ulTotalPhysicalMemoryPages  = DataBuf[QSV_TOTPHYSMEM - 1];
  722.     sys_settings.ulTotalResidentMemoryPages  = DataBuf[QSV_TOTRESMEM - 1];
  723.     sys_settings.ulTotalAvailableMemoryPages = DataBuf[QSV_TOTAVAILMEM - 1];
  724.     sys_settings.ulTotalMaxPrivateMemory_by  = DataBuf[QSV_MAXPRMEM - 1];
  725.     sys_settings.ulTotalMaxSharedMemory_by   = DataBuf[QSV_MAXSHMEM - 1];
  726.     sys_settings.ulTimerInterval             = DataBuf[QSV_TIMER_INTERVAL - 1];
  727.     sys_settings.ulMaxComponentLength_by     = DataBuf[QSV_MAX_COMP_LENGTH - 1];
  728.  
  729.      rc = system_info_out(hwnd);
  730.     }
  731. }
  732.  
  733. /***************************************/
  734. /*                                     */
  735. /*       Display System Information    */
  736. /*                                     */
  737. /***************************************/
  738. INT EXPENTRY system_info_out(HWND hwnd)
  739. {
  740.     char pTemp[30]    = "\0";
  741.     short rc;
  742.  
  743.    ltoa(sys_settings.ulMaxPath, pTemp, 10);
  744.    WinSetDlgItemText(hwnd, IDD_DIS_MAX_PATH_FLD, pTemp);
  745.     strcpy(pTemp,"\0");
  746.  
  747.    ltoa(sys_settings.ulMaxTextSessions, pTemp, 10);
  748.    WinSetDlgItemText(hwnd, IDD_DIS_MAX_TEXT_FLD, pTemp);
  749.  
  750.     ltoa(sys_settings.ulMaxPMSessions                   , pTemp, 10);
  751.    WinSetDlgItemText(hwnd, IDD_DIS_MAX_PMSESS_FLD, pTemp);
  752.  
  753.     ltoa(sys_settings.ulMaxVDMSessions                   , pTemp, 10);
  754.    WinSetDlgItemText(hwnd, IDD_DIS_MAX_VDMSESS_FLD, pTemp);
  755.  
  756.     ltoa(sys_settings.ulBootDrive                     , pTemp, 10);  
  757.    WinSetDlgItemText(hwnd, IDD_DIS_BOOTDRIVE_FLD, pTemp);
  758.  
  759.     ltoa(sys_settings.ulDynamicPriorityVariation , pTemp, 10);
  760.    WinSetDlgItemText(hwnd, IDD_DIS_DYNPRI_FLD, pTemp);
  761.  
  762.     ltoa(sys_settings.ulMaxWait_sec                       , pTemp, 10);
  763.    WinSetDlgItemText(hwnd, IDD_DIS_MAX_WAIT_FLD, pTemp);
  764.     strcpy(pTemp,"\0");
  765.  
  766.     ltoa(sys_settings.ulMinTimeSlice_ms             , pTemp, 10);  
  767.    WinSetDlgItemText(hwnd, IDD_DIS_MIN_TIMESLICE_FLD, pTemp);
  768.     strcpy(pTemp,"\0");
  769.  
  770.     ltoa(sys_settings.ulMaxTimeSlice_ms             , pTemp, 10);  
  771.    WinSetDlgItemText(hwnd, IDD_DIS_MAX_TIMESLICE_FLD, pTemp);
  772.     strcpy(pTemp,"\0");
  773.  
  774.     ltoa(sys_settings.ulPageSize_by                       , pTemp, 10);
  775.    WinSetDlgItemText(hwnd, IDD_DIS_PAGESIZE_FLD, pTemp);
  776.     strcpy(pTemp,"\0");
  777.  
  778.     ltoa(sys_settings.ulMilliSecCounter             , pTemp, 10);  
  779.    WinSetDlgItemText(hwnd, IDD_DIS_MS_COUNTER_FLD, pTemp);
  780.  
  781.     ltoa(sys_settings.ulLowOrdTime                       , pTemp, 10);
  782.    WinSetDlgItemText(hwnd, IDD_DIS_LO_TIME_FLD, pTemp);
  783.  
  784.     ltoa(sys_settings.ulHighOrdTime                       , pTemp, 10);
  785.    WinSetDlgItemText(hwnd, IDD_DIS_HI_TIME_FLD, pTemp);
  786.  
  787.     ltoa(sys_settings.ulTotalPhysicalMemoryPages , pTemp, 10);
  788.    WinSetDlgItemText(hwnd, IDD_DIS_TOT_PHY_MEM_FLD, pTemp);
  789.     strcpy(pTemp,"\0");
  790.  
  791.     ltoa(sys_settings.ulTotalResidentMemoryPages , pTemp, 10);
  792.    WinSetDlgItemText(hwnd, IDD_DIS_TOT_RES_MEM_FLD, pTemp);
  793.     strcpy(pTemp,"\0");
  794.  
  795.     ltoa(sys_settings.ulTotalAvailableMemoryPages, pTemp, 10);
  796.    WinSetDlgItemText(hwnd, IDD_DIS_TOT_AVAIL_MEM_FLD, pTemp);
  797.     strcpy(pTemp,"\0");
  798.  
  799.     ltoa(sys_settings.ulTotalMaxPrivateMemory_by , pTemp, 10);
  800.    WinSetDlgItemText(hwnd, IDD_DIS_MAX_PRIVATE_MEM_FLD, pTemp);
  801.     strcpy(pTemp,"\0");
  802.  
  803.     ltoa(sys_settings.ulTotalMaxSharedMemory_by  , pTemp, 10);
  804.    WinSetDlgItemText(hwnd, IDD_DIS_MAX_SHARED_MEM_FLD, pTemp);
  805.     strcpy(pTemp,"\0");
  806.  
  807.     ltoa(sys_settings.ulTimerInterval                   , pTemp, 10);
  808.     strcat(pTemp," .10/ms");
  809.    WinSetDlgItemText(hwnd, IDD_DIS_TIME_INTERVAL_FLD, pTemp);
  810.     strcpy(pTemp,"\0");
  811.  
  812.     ltoa(sys_settings.ulMaxComponentLength_by     , pTemp, 10);  
  813.    WinSetDlgItemText(hwnd, IDD_DIS_MAX_COMP_LEN_FLD, pTemp);
  814.     strcpy(pTemp,"\0");
  815.  
  816.   return 0;
  817. }
  818.