home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bde / snipit.pak / SYSINFO.C < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-24  |  4.5 KB  |  121 lines

  1. // BDE - (C) Copyright 1995 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.     SYSVersion  sysVersion;     // Version information
  18.     SYSConfig   sysConfig;      // Configuration information
  19.     CLIENTInfo  clientInfo;     // Client information
  20.     SYSInfo     sysInfo;        // System information
  21.  
  22.     CHAR        szDate[12];     // String to hold the date
  23.     UINT16      uMonth;         // Month of the year
  24.     UINT16      uDay;           // Day of the month
  25.     INT16       iYear;          // Year
  26.  
  27.     CHAR        szTime[12];     // String to contain the time
  28.     UINT16      uHour;          // Hour
  29.     UINT16      uMin;           // Minute
  30.     UINT16      uMilSec;        // Millisecond
  31.  
  32.     Screen("*** Getting system information ***\r\n");
  33.  
  34.     BREAK_IN_DEBUGGER();
  35.  
  36.     Screen("\r\n    Initializing IDAPI...");
  37.     rslt = DbiInit(NULL);
  38.     if (ChkRslt(rslt, "Init") != DBIERR_NONE)
  39.     {
  40.         Screen("\r\n*** End of Example ***");
  41.         return;
  42.     }
  43.  
  44.     // Turn on trace information if the debug layer is anabled (DLLSWAP.EXE).
  45.     DbiDebugLayerOptions(DEBUGON | OUTPUTTOFILE, "SNIPIT.INF");
  46.  
  47.     // Specify where temporary files are placed.
  48.     rslt = DbiSetPrivateDir(szPrivDirectory);
  49.     ChkRslt(rslt, "SetPrivateDir");
  50.     
  51.     Screen("\r\n    Getting system version info...");
  52.     rslt = DbiGetSysVersion(&sysVersion);
  53.     ChkRslt(rslt, "GetSysVersion");
  54.  
  55.     // Format the date to MM\DD\YYYY format.
  56.     rslt = DbiDateDecode(sysVersion.dateVer, &uMonth, &uDay, &iYear);
  57.     ChkRslt(rslt, "DateEncode");
  58.     wsprintf(szDate, "%u\\%u\\%u", uMonth, uDay, iYear);
  59.  
  60.     // Format the time to HH:MM:SS format.
  61.     rslt = DbiTimeDecode(sysVersion.timeVer, &uHour, &uMin, &uMilSec);
  62.     ChkRslt(rslt, "TimeEncode");
  63.     wsprintf(szTime, "%02u:%02u:%02u", uHour, uMin, (uMilSec / 1000));
  64.  
  65.     // Display the version information.
  66.     Screen("        IDAPI Version:   %d", sysVersion.iVersion);
  67.     Screen("        Interface Level: %d", sysVersion.iIntfLevel);
  68.     Screen("        Version Date:    %s", szDate);
  69.     Screen("        Version Time:    %s", szTime);
  70.  
  71.     Screen("\r\n    Getting system configuration information...");
  72.     rslt = DbiGetSysConfig(&sysConfig);
  73.     ChkRslt(rslt, "GetSysConfig");
  74.  
  75.     // Display configuration information.
  76.     Screen("        Share Local Tables  : %s",
  77.            (sysConfig.bLocalShare ? "TRUE" : "FALSE"));
  78.     Screen("        Share Network Tables: %s",
  79.            (sysConfig.bNetShare ? "TRUE" : "FALSE"));
  80.     Screen("        Net Protocol:         %d", sysConfig.iNetProtocol);
  81.     Screen("        Network Type:         %s", sysConfig.szNetType);
  82.     Screen("        User Name:            %s", sysConfig.szUserName);
  83.     Screen("        Config File:          %s", sysConfig.szIniFile);
  84.     Screen("        Language Driver:      %s", sysConfig.szLangDriver);
  85.  
  86.     Screen("\r\n    Getting Client Information...");
  87.     rslt = DbiGetClientInfo(&clientInfo);
  88.     ChkRslt(rslt, "GetClientInfo");
  89.  
  90.     // Display client information.
  91.     Screen("        Documentary name:                  %s",
  92.            clientInfo.szName);
  93.     Screen("        Number of sessions:                %d",
  94.            clientInfo.iSessions);
  95.     Screen("        Working directory:                 %s",
  96.            clientInfo.szWorkDir);
  97.     Screen("        Client language(for messages):     %s",
  98.            clientInfo.szLang);
  99.  
  100.     Screen("\r\n    Getting system status information...");
  101.     rslt = DbiGetSysInfo(&sysInfo);
  102.     ChkRslt(rslt, "GetSysInfo");
  103.  
  104.     // Display system status information.
  105.     Screen("        %dK Buffer Space %dK Heap Space",
  106.            sysInfo.iBufferSpace, sysInfo.iHeapSpace);
  107.     Screen("        Active: %d driver(s), %d client(s), %d session(s)",
  108.            sysInfo.iDrivers, sysInfo.iClients, sysInfo.iSessions);
  109.     Screen("        Open  : %d Database(s), %d Cursor(s)",
  110.            sysInfo.iDatabases, sysInfo.iCursors);
  111.  
  112.     // Turn off trace information.
  113.     DbiDebugLayerOptions(0, NULL);
  114.  
  115.     // Exit IDAPI.
  116.     rslt = DbiExit();
  117.     ChkRslt(rslt, "Exit");
  118.  
  119.     Screen("\r\n*** End of example ***");
  120. }
  121.