home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 April B / Pcwk4b98.iso / Borland / Dbase50w / SAMPLES1.PAK / SYSINFO.WFM < prev    next >
Text File  |  1994-08-02  |  10KB  |  344 lines

  1. **************************************************************************
  2. *  PROGRAM:      Sysinfo.wfm
  3. *
  4. *  WRITTEN BY:   Borland Samples Group
  5. *
  6. *  DATE:         5/93
  7. *
  8. *  UPDATED:      7/94
  9. *
  10. *  REVISION:     $Revision:   1.43  $
  11. *
  12. *  VERSION:      dBASE FOR WINDOWS 5.0
  13. *
  14. *  DESCRIPTION:  This form displays information about your system.
  15. *                It uses Windows API functions called externally from
  16. *                dBASE for Windows to obtain that information.
  17. *
  18. *  PARAMETERS:   None
  19. *
  20. *  CALLS:        Buttons.cc      (for custom pushbuttons)
  21. *
  22. *  USAGE:        do Sysinfo.wfm
  23. *                or
  24. *                set procedure to Sysinfo.wfm additive
  25. *                local f
  26. *                f = new SysInfo()
  27. *                f.mdi = .f.       && modal forms cannot be mdi
  28. *                f.ReadModal()
  29. *
  30. *******************************************************************************
  31. create session
  32. set talk off
  33. set ldCheck off
  34.  
  35. ** END HEADER -- do not remove this line*
  36. * Generated on 05/11/94
  37. *
  38. LOCAL f
  39. f = NEW SYSINFOFORM ()
  40. f.Open()
  41.  
  42. CLASS SYSINFOFORM OF FORM
  43.    Set Procedure to Buttons.cc additive
  44.    this.OnOpen = CLASS::ONOPEN
  45.    this.OnClose = CLASS::ONCLOSE
  46.    this.MDI = .F.
  47.    this.MousePointer =          1
  48.    this.Text = "Windows System Information"
  49.    this.Width =         52.79
  50.    this.Top =          8.42
  51.    this.Left =         26.39
  52.    this.Height =         13.13
  53.    this.Minimize = .F.
  54.    this.Maximize = .F.
  55.    this.HelpFile = ""
  56.    this.HelpId = ""
  57.  
  58.    DEFINE RECTANGLE RECTANGLE1 OF THIS;
  59.        PROPERTY;
  60.          ColorNormal "N/W",;
  61.          Text "",;
  62.          Height          10.07,;
  63.          Width         50.15,;
  64.          Top          0.54,;
  65.          Left          1.32,;
  66.          Border .T.
  67.  
  68.    DEFINE TEXT INSTANCESTEXT OF THIS;
  69.        PROPERTY;
  70.          ColorNormal "N/W",;
  71.          Text "Number of Instances:",;
  72.          Width         23.75,;
  73.          Top          1.06,;
  74.          Left          2.64,;
  75.          Height          1.32,;
  76.          Border .F.,;
  77.          Alignment          2
  78.  
  79.    DEFINE TEXT WINVERSIONTEXT OF THIS;
  80.        PROPERTY;
  81.          MousePointer          1,;
  82.          ColorNormal "N/W",;
  83.          Text "Windows Version:",;
  84.          Width         23.75,;
  85.          Top          2.38,;
  86.          Left          2.64,;
  87.          Height          1.32,;
  88.          Border .F.,;
  89.          Alignment          2
  90.  
  91.    DEFINE TEXT MODETEXT OF THIS;
  92.        PROPERTY;
  93.          MousePointer          1,;
  94.          ColorNormal "N/W",;
  95.          Text "Mode of Operation:",;
  96.          Width         23.75,;
  97.          Top          3.72,;
  98.          Left          2.64,;
  99.          Height          1.32,;
  100.          Border .F.,;
  101.          Alignment          2
  102.  
  103.    DEFINE TEXT CPUTEXT OF THIS;
  104.        PROPERTY;
  105.          MousePointer          1,;
  106.          ColorNormal "N/W",;
  107.          Text "CPU Type:",;
  108.          Width         23.75,;
  109.          Top          5.04,;
  110.          Left          2.64,;
  111.          Height          1.32,;
  112.          Border .F.,;
  113.          Alignment          2
  114.  
  115.    DEFINE TEXT COPROCTEXT OF THIS;
  116.        PROPERTY;
  117.          MousePointer          1,;
  118.          ColorNormal "N/W",;
  119.          Text "Coprocessor Present:",;
  120.          Width         23.75,;
  121.          Top          6.36,;
  122.          Left          2.64,;
  123.          Height          1.32,;
  124.          Border .F.,;
  125.          Alignment          2
  126.  
  127.    DEFINE TEXT GLOBFREETEXT OF THIS;
  128.        PROPERTY;
  129.          MousePointer          1,;
  130.          ColorNormal "N/W",;
  131.          Text "Free Global Memory:",;
  132.          Width         23.75,;
  133.          Top          7.69,;
  134.          Left          2.64,;
  135.          Height          1.32,;
  136.          Border .F.,;
  137.          Alignment          2
  138.  
  139.    DEFINE TEXT DOSVERSTEXT OF THIS;
  140.        PROPERTY;
  141.          MousePointer          1,;
  142.          ColorNormal "N/W",;
  143.          Text "DOS Version:",;
  144.          Width         23.75,;
  145.          Top          9.01,;
  146.          Left          2.64,;
  147.          Height          1.32,;
  148.          Border .F.,;
  149.          Alignment          2
  150.  
  151.    DEFINE ENTRYFIELD INSTANCESENTRY OF THIS;
  152.        PROPERTY;
  153.          Enabled .F.,;
  154.          ColorNormal "B/W",;
  155.          Width         19.80,;
  156.          Top          1.06,;
  157.          Left         27.71,;
  158.          Height          1.32,;
  159.          ColorHighLight "",;
  160.          Value "                    ",;
  161.          Border .F.
  162.  
  163.    DEFINE ENTRYFIELD WINVERSIONENTRY OF THIS;
  164.        PROPERTY;
  165.          Enabled .F.,;
  166.          ColorNormal "B/W",;
  167.          Width         19.80,;
  168.          Top          2.38,;
  169.          Left         27.71,;
  170.          Height          1.32,;
  171.          ColorHighLight "",;
  172.          Value "                     ",;
  173.          Border .F.
  174.  
  175.    DEFINE ENTRYFIELD MODEENTRY OF THIS;
  176.        PROPERTY;
  177.          Enabled .F.,;
  178.          ColorNormal "B/W",;
  179.          Width         23.10,;
  180.          Top          3.72,;
  181.          Left         27.71,;
  182.          Height          1.32,;
  183.          ColorHighLight "",;
  184.          Value "                      ",;
  185.          Border .F.
  186.  
  187.    DEFINE ENTRYFIELD CPUENTRY OF THIS;
  188.        PROPERTY;
  189.          Enabled .F.,;
  190.          ColorNormal "B/W",;
  191.          Width         19.80,;
  192.          Top          5.04,;
  193.          Left         27.71,;
  194.          Height          1.32,;
  195.          ColorHighLight "",;
  196.          Value "                     ",;
  197.          Border .F.
  198.  
  199.    DEFINE ENTRYFIELD COPROCENTRY OF THIS;
  200.        PROPERTY;
  201.          Enabled .F.,;
  202.          ColorNormal "B/W",;
  203.          Width         19.80,;
  204.          Top          6.36,;
  205.          Left         27.71,;
  206.          Height          1.32,;
  207.          ColorHighLight "",;
  208.          Value "                      ",;
  209.          Border .F.
  210.  
  211.    DEFINE ENTRYFIELD GLOBFREEENTRY OF THIS;
  212.        PROPERTY;
  213.          Enabled .F.,;
  214.          ColorNormal "B/W",;
  215.          Width         19.80,;
  216.          Top          7.69,;
  217.          Left         27.71,;
  218.          Height          1.32,;
  219.          ColorHighLight "",;
  220.          Value "                      ",;
  221.          Border .F.
  222.  
  223.    DEFINE ENTRYFIELD DOSVERSENTRY OF THIS;
  224.        PROPERTY;
  225.          Enabled .F.,;
  226.          ColorNormal "B/W",;
  227.          Width         19.80,;
  228.          Top          9.01,;
  229.          Left         27.71,;
  230.          Height          1.32,;
  231.          ColorHighLight "",;
  232.          Value "                      ",;
  233.          Border .F.
  234.  
  235.    DEFINE CLOSEBUTTON CLOSEBUTTON1 OF THIS;
  236.        PROPERTY;
  237.          Width         14.11,;
  238.          Top         11.14,;
  239.          Left         19.14,;
  240.          Height          1.50
  241.  
  242. ********************************************************************************
  243. procedure OnOpen
  244.  
  245. * Called by Sysinfo().  This function makes the necessary API calls, and assigns
  246. * the accessed information to variables that will be displayed in the form
  247. * showing system information.
  248. *
  249. ********************************************************************************
  250. #include "winapi.h"
  251. *extern  CLONG     GetFreeSpace ( CINT )  KRNL386.EXE
  252.  
  253. set procedure to Sampproc.prg additive && for Format functions
  254.  
  255. local mHandle,mInstance,mFlags,mCpu,mFreeMem,wFreeMem,mCoprocess
  256.  
  257. mHandle = GetModuleHandle(ansi("DBASEWIN.EXE")) && "SYSINFO"
  258. ShowWindow(mHandle,7) && 7 make icon not active
  259. mInstance = GetModuleUsage(mHandle)
  260. mFlags = GetWinFlags()
  261. do case                                && Check which mode Windows is running in
  262.    case mFlags = BitOr(mFlags,2)
  263.       mMode = "Running Win286"
  264.    case mFlags = BitOr(mFlags,16)
  265.       mMode = "Standard Mode"
  266.    case mFlags = BitOr(mFlags,32)
  267.       mMode = "Enhanced Mode"
  268. endcase
  269. do case                                && Check processor type
  270.    case mFlags = BitOr(mFlags,8)
  271.       mCpu = "80486"
  272.    case mFlags = BitOr(mFlags,4)
  273.       mCpu = "80386"
  274.    case mFlags = BitOr(mFlags,2)
  275.       mCpu = "80286"
  276.    case mFlags = BitOr(mFlags,128)
  277.       mCpu = "80186"
  278.    case mFlags = BitOr(mFlags,64)
  279.       mCpu = "8086"
  280. endcase
  281. mCoprocess = IIF(mFlags = BitOr(mFlags,1024), "Yes", "No ")
  282. mFreeMem = FormatStr("%1 K", ltrim(str(memo())))
  283. wFreeMem = FormatStr("%1 K", ltrim(str(GetFreeSpace(0)/1024)))
  284.  
  285. form.instancesEntry.value = ltrim(str(mInstance))
  286. form.winVersionEntry.value = gVer("WIN")
  287. form.modeEntry.value = mMode
  288. form.cpuEntry.value = mCpu
  289. form.coprocEntry.value = mCoprocess
  290. form.globFreeEntry.value = wFreeMem
  291. form.dosVersEntry.value = gVer("DOS")
  292.  
  293. form.visible = .T.   && Workaround -- so you don't see all controls painting
  294.                      && while they are defined
  295.  
  296. ********************************************************************************
  297. procedure OnClose
  298. ********************************************************************************
  299. close procedure Buttons.cc
  300.  
  301. ENDCLASS
  302.  
  303. ********************************************************************************
  304. procedure GVer (verType)
  305. *
  306. * Gets information from the Windows function
  307. * GetVersion(), which returns the major and minor
  308. * DOS and Windows versions as a CLONG.
  309. *
  310. *
  311. * The "High Byte of the High Word" contains the
  312. * major DOS version, the "Low Byte of the High Word"
  313. * contains the minor DOS version. The "High Byte of
  314. * the Low Word" specifies the minor version of
  315. * Windows and the "Low byte of the Low Word"
  316. * specifies the major Windows version. The Bit
  317. * functions are used to extract the proper values.
  318. * BitRshift(), BitAnd().
  319. *
  320. ********************************************************************************
  321.  
  322. #define HIWORD(x)     (bitand(bitrshift(x,16),2^16-1))
  323. #define LOWORD(x)     (bitand(x,2^16-1))
  324. #define HIBYTE(x)     (bitand(bitrshift(x,8),2^8-1))
  325. #define LOBYTE(x)     (bitand(x,2^8-1))
  326. #define STRHIBYTE(x)  ltrim(str(HIBYTE(x)))
  327. #define STRLOBYTE(x)  ltrim(str(LOBYTE(x)))
  328.  
  329. * EXTERN CLONG GetVersion(CVOID)  krnl386.exe
  330. local version,retVal
  331. version = GetVersion( )
  332. if upper(verType) = "DOS"
  333.    retVal = FormatStr("%1.%2",;
  334.       STRHIBYTE(HIWORD(version)), STRLOBYTE(HIWORD(version)))
  335. elseif left(upper(verType),3) = "WIN"
  336.    retVal = FormatStr("%1.%2",;
  337.       STRLOBYTE(LOWORD(version)), STRHIBYTE(LOWORD(version)))
  338. endif
  339.  
  340. return retVal
  341.  
  342.  
  343.  
  344.