home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / 32SNIPIT.PAK / SYSINFO.C < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  4.1 KB  |  112 lines

  1. // BDE32 3.x - (C) Copyright 1996 by Borland International
  2.  
  3. // SysInfo.c
  4. #include "snipit.h"
  5.  
  6. //=====================================================================
  7. //  Function:
  8. //          SysInfo();
  9. //
  10. //  Description:
  11. //          This example displays information about the system.
  12. //=====================================================================
  13. void
  14. SysInfo (void)
  15. {
  16.     DBIResult   rslt;           // Value returned from IDAPI functions
  17.  
  18.     SYSVersion  sysVersion;     // Version information
  19.     SYSConfig   sysConfig;      // Configuration information
  20.     CLIENTInfo  clientInfo;     // Client information
  21.     SYSInfo     sysInfo;        // System information
  22.  
  23.     CHAR        szDate[12];     // String to hold the date
  24.     UINT16      uMonth;         // Month of the year
  25.     UINT16      uDay;           // Day of the month
  26.     INT16       iYear;          // Year
  27.  
  28.     CHAR        szTime[12];     // String to contain the time
  29.     UINT16      uHour;          // Hour
  30.     UINT16      uMin;           // Minute
  31.     UINT16      uMilSec;        // Millisecond
  32.  
  33.     Screen("*** Getting system information ***\r\n");
  34.  
  35.     BREAK_IN_DEBUGGER();
  36.  
  37.     Screen("\r\n    Initializing IDAPI...");
  38.     rslt = DbiInit(NULL);
  39.     if (ChkRslt(rslt, "Init") != DBIERR_NONE)
  40.     {
  41.         Screen("\r\n*** End of Example ***");
  42.         return;
  43.     }
  44.  
  45.     Screen("\r\n    Getting system version info...");
  46.     rslt = DbiGetSysVersion(&sysVersion);
  47.     ChkRslt(rslt, "GetSysVersion");
  48.  
  49.     // Format the date to MM\DD\YYYY format
  50.     rslt = DbiDateDecode(sysVersion.dateVer, &uMonth, &uDay, &iYear);
  51.     ChkRslt(rslt, "DateEncode");
  52.     wsprintf(szDate, "%u\\%u\\%u", uMonth, uDay, iYear);
  53.  
  54.     // Format the time to HH:MM:SS format
  55.     rslt = DbiTimeDecode(sysVersion.timeVer, &uHour, &uMin, &uMilSec);
  56.     ChkRslt(rslt, "TimeEncode");
  57.     wsprintf(szTime, "%02u:%02u:%02u", uHour, uMin, (uMilSec / 1000));
  58.  
  59.     // Display the version information
  60.     Screen("        IDAPI Version:   %d", sysVersion.iVersion);
  61.     Screen("        Interface Level: %d", sysVersion.iIntfLevel);
  62.     Screen("        Version Date:    %s", szDate);
  63.     Screen("        Version Time:    %s", szTime);
  64.  
  65.     Screen("\r\n    Getting system configuration Information...");
  66.     rslt = DbiGetSysConfig(&sysConfig);
  67.     ChkRslt(rslt, "GetSysConfig");
  68.  
  69.     // Display configuration information
  70.     Screen("        Share Local Tables  : %s",
  71.            (sysConfig.bLocalShare ? "TRUE" : "FALSE"));
  72.     Screen("        Share Network Tables: %s",
  73.            (sysConfig.bNetShare ? "TRUE" : "FALSE"));
  74.     Screen("        Net Protocol:         %d", sysConfig.iNetProtocol);
  75.     Screen("        Network Type:         %s", sysConfig.szNetType);
  76.     Screen("        User Name:            %s", sysConfig.szUserName);
  77.     Screen("        Config File:          %s", sysConfig.szIniFile);
  78.     Screen("        Lang. Driver:         %s", sysConfig.szLangDriver);
  79.  
  80.     Screen("\r\n    Getting Client Information...");
  81.     rslt = DbiGetClientInfo(&clientInfo);
  82.     ChkRslt(rslt, "GetClientInfo");
  83.  
  84.     // Display Client information
  85.     Screen("        Documentary Name:                  %s",
  86.            clientInfo.szName);
  87.     Screen("        No. of Sessions:                   %d",
  88.            clientInfo.iSessions);
  89.     Screen("        Working Directory:                 %s",
  90.            clientInfo.szWorkDir);
  91.     Screen("        Client Language(for messages):     %s",
  92.            clientInfo.szLang);
  93.  
  94.     Screen("\r\n    Getting system status information...");
  95.     rslt = DbiGetSysInfo(&sysInfo);
  96.     ChkRslt(rslt, "GetSysInfo");
  97.  
  98.     // Display system status information
  99.     Screen("        %dK Buffer Space %dK Heap Space",
  100.            sysInfo.iBufferSpace, sysInfo.iHeapSpace);
  101.     Screen("        Active: %d driver(s), %d client(s), %d session(s)",
  102.            sysInfo.iDrivers, sysInfo.iClients, sysInfo.iSessions);
  103.     Screen("        Open  : %d Database(s), %d Cursor(s)",
  104.            sysInfo.iDatabases, sysInfo.iCursors);
  105.  
  106.     // Exit IDAPI
  107.     rslt = DbiExit();
  108.     ChkRslt(rslt, "Exit");
  109.  
  110.     Screen("\r\n*** End of example ***");
  111. }
  112.