home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / rwp15.zip / SYSINFO.C < prev    next >
C/C++ Source or Header  |  1993-03-24  |  3KB  |  109 lines

  1. /* --------------------------------------------------------------------
  2.                           System Information
  3.                               Chapter 15
  4.  
  5.                     Real World Programming for OS/2
  6.              Copyright (c) 1993 Blain, Delimon, and English
  7. -------------------------------------------------------------------- */
  8.  
  9. #define INCL_DOS
  10. #define INCL_WIN
  11. #define INCL_ERRORS
  12.  
  13. #include <os2.h>
  14. #include <stdio.h>
  15. #include "sysinfo.h"
  16.  
  17. /* Local Functions    */
  18. VOID QueryAllValues (HWND);
  19.  
  20. /* External variables */
  21. extern HAB       hab;                    /* Handle to anchor block       */
  22.  
  23. CHAR szSysValues[QSV_MAX][18] =
  24.     {
  25.         "MAX_PATH_LENGTH  ",
  26.         "MAX_TEXT_SESSIONS",
  27.         "MAX_PM_SESSIONS  ",
  28.         "MAX_VDM_SESSIONS ",
  29.         "BOOT_DRIVE       ",
  30.         "DYN_PRI_VARIATION",
  31.         "MAX_WAIT         ",
  32.         "MIN_SLICE        ",
  33.         "MAX_SLICE        ",
  34.         "PAGE_SIZE        ",
  35.         "VERSION_MAJOR    ",
  36.         "VERSION_MINOR    ",
  37.         "VERSION_REVISION ",
  38.         "MS_COUNT         ",
  39.         "TIME_LOW         ",
  40.         "TIME_HIGH        ",
  41.         "TOTPHYSMEM       ",
  42.         "TOTRESMEM        ",
  43.         "TOTAVAILMEM      ",
  44.         "MAXPRMEM         ",
  45.         "MAXSHMEM         ",
  46.         "TIMER_INTERVAL   ",
  47.         "MAX_COMP_LENGTH  "
  48.     };
  49.  
  50. /* ----------------------- Local Functions ----------------------- */
  51.  
  52. VOID QueryAllValues (HWND hWnd)
  53.     ULONG ulValues[QSV_MAX];
  54.     CHAR  szText[31];
  55.     ULONG ulInx;
  56.  
  57.     DosQuerySysInfo (QSV_MAX_PATH_LENGTH, QSV_MAX, &ulValues, sizeof(ulValues));
  58.  
  59.     for (ulInx = 0; ulInx < QSV_MAX; ulInx++)
  60.     {
  61.         sprintf (szText, "%17s   0x%08lx", szSysValues[ulInx], ulValues[ulInx]);
  62.         WinUpper (hab, 0, 0, szText);
  63.         szText[21] = 'x';
  64.         WinSendDlgItemMsg (hWnd, IDC_SYSINFOLIST, LM_INSERTITEM, (MPARAM)LIT_END,
  65.             szText);
  66.     }        
  67.     return;
  68. }
  69.  
  70. /* ----------------------  Dialog Function ----------------------- */
  71.  
  72. MRESULT EXPENTRY SysInfoDlgProc (HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  73. {
  74.     BOOL    bHandled = TRUE;
  75.     MRESULT mReturn  = 0;
  76.     HWND    hWndListBox;
  77.     SWP     Swp;
  78.  
  79.     switch (msg)
  80.     {           
  81.         case WM_INITDLG:
  82.             QueryAllValues (hWnd);
  83.             break;
  84.  
  85.         case WM_WINDOWPOSCHANGED:
  86.             if (((PSWP)mp1)->fl & SWP_SHOW)
  87.             {
  88.                 /* Center the listbox horizontally in the window */
  89.                 hWndListBox = WinWindowFromID (hWnd, IDC_SYSINFOLIST);
  90.                 WinQueryWindowPos (hWndListBox, &Swp);
  91.                 WinSetWindowPos (hWndListBox, 0L,
  92.                     (((PSWP)mp1)->cx - Swp.cx) >> 1, Swp.y, 0L, 0L, SWP_MOVE);
  93.             }
  94.             bHandled = FALSE;
  95.             break;
  96.  
  97.         default:
  98.             bHandled = FALSE;
  99.             break;
  100.     }
  101.  
  102.     if (!bHandled)
  103.         mReturn = WinDefDlgProc (hWnd, msg, mp1, mp2);
  104.  
  105.     return (mReturn);
  106. }
  107.  
  108.