home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 6 / mastvb6.iso / ch_code / ch13 / memstat / memstat.frm (.txt) next >
Encoding:
Visual Basic Form  |  1996-04-26  |  11.4 KB  |  354 lines

  1. VERSION 5.00
  2. Begin VB.Form MemStatusForm 
  3.    Caption         =   "Memory Status"
  4.    ClientHeight    =   4875
  5.    ClientLeft      =   60
  6.    ClientTop       =   330
  7.    ClientWidth     =   5070
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   4875
  10.    ScaleWidth      =   5070
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.CommandButton Command1 
  13.       Caption         =   "Memory Status"
  14.       BeginProperty Font 
  15.          Name            =   "Verdana"
  16.          Size            =   11.25
  17.          Charset         =   0
  18.          Weight          =   400
  19.          Underline       =   0   'False
  20.          Italic          =   0   'False
  21.          Strikethrough   =   0   'False
  22.       EndProperty
  23.       Height          =   615
  24.       Left            =   1080
  25.       TabIndex        =   14
  26.       Top             =   4140
  27.       Width           =   2895
  28.    End
  29.    Begin VB.Label Label1 
  30.       Alignment       =   1  'Right Justify
  31.       BeginProperty Font 
  32.          Name            =   "Verdana"
  33.          Size            =   9
  34.          Charset         =   0
  35.          Weight          =   400
  36.          Underline       =   0   'False
  37.          Italic          =   0   'False
  38.          Strikethrough   =   0   'False
  39.       EndProperty
  40.       Height          =   255
  41.       Index           =   7
  42.       Left            =   3015
  43.       TabIndex        =   16
  44.       Top             =   3600
  45.       Width           =   1560
  46.    End
  47.    Begin VB.Label Label1 
  48.       Caption         =   "Virtual Bytes in Use"
  49.       BeginProperty Font 
  50.          Name            =   "Verdana"
  51.          Size            =   9
  52.          Charset         =   0
  53.          Weight          =   400
  54.          Underline       =   0   'False
  55.          Italic          =   0   'False
  56.          Strikethrough   =   0   'False
  57.       EndProperty
  58.       Height          =   255
  59.       Index           =   15
  60.       Left            =   105
  61.       TabIndex        =   15
  62.       Top             =   3585
  63.       Width           =   2715
  64.    End
  65.    Begin VB.Label Label1 
  66.       Caption         =   "Free Virtual Bytes:"
  67.       BeginProperty Font 
  68.          Name            =   "Verdana"
  69.          Size            =   9
  70.          Charset         =   0
  71.          Weight          =   400
  72.          Underline       =   0   'False
  73.          Italic          =   0   'False
  74.          Strikethrough   =   0   'False
  75.       EndProperty
  76.       Height          =   255
  77.       Index           =   14
  78.       Left            =   120
  79.       TabIndex        =   13
  80.       Top             =   3120
  81.       Width           =   2715
  82.    End
  83.    Begin VB.Label Label1 
  84.       Caption         =   "Total Virtual Bytes:"
  85.       BeginProperty Font 
  86.          Name            =   "Verdana"
  87.          Size            =   9
  88.          Charset         =   0
  89.          Weight          =   400
  90.          Underline       =   0   'False
  91.          Italic          =   0   'False
  92.          Strikethrough   =   0   'False
  93.       EndProperty
  94.       Height          =   255
  95.       Index           =   13
  96.       Left            =   120
  97.       TabIndex        =   12
  98.       Top             =   2640
  99.       Width           =   2715
  100.    End
  101.    Begin VB.Label Label1 
  102.       Caption         =   "Paging File Free Bytes:"
  103.       BeginProperty Font 
  104.          Name            =   "Verdana"
  105.          Size            =   9
  106.          Charset         =   0
  107.          Weight          =   400
  108.          Underline       =   0   'False
  109.          Italic          =   0   'False
  110.          Strikethrough   =   0   'False
  111.       EndProperty
  112.       Height          =   255
  113.       Index           =   12
  114.       Left            =   120
  115.       TabIndex        =   11
  116.       Top             =   2160
  117.       Width           =   2715
  118.    End
  119.    Begin VB.Label Label1 
  120.       Caption         =   "Page File Bytes:"
  121.       BeginProperty Font 
  122.          Name            =   "Verdana"
  123.          Size            =   9
  124.          Charset         =   0
  125.          Weight          =   400
  126.          Underline       =   0   'False
  127.          Italic          =   0   'False
  128.          Strikethrough   =   0   'False
  129.       EndProperty
  130.       Height          =   255
  131.       Index           =   11
  132.       Left            =   120
  133.       TabIndex        =   10
  134.       Top             =   1680
  135.       Width           =   2715
  136.    End
  137.    Begin VB.Label Label1 
  138.       Caption         =   "Available Physical Bytes:"
  139.       BeginProperty Font 
  140.          Name            =   "Verdana"
  141.          Size            =   9
  142.          Charset         =   0
  143.          Weight          =   400
  144.          Underline       =   0   'False
  145.          Italic          =   0   'False
  146.          Strikethrough   =   0   'False
  147.       EndProperty
  148.       Height          =   255
  149.       Index           =   10
  150.       Left            =   120
  151.       TabIndex        =   9
  152.       Top             =   1200
  153.       Width           =   2715
  154.    End
  155.    Begin VB.Label Label1 
  156.       Caption         =   "Total Physical Bytes:"
  157.       BeginProperty Font 
  158.          Name            =   "Verdana"
  159.          Size            =   9
  160.          Charset         =   0
  161.          Weight          =   400
  162.          Underline       =   0   'False
  163.          Italic          =   0   'False
  164.          Strikethrough   =   0   'False
  165.       EndProperty
  166.       Height          =   255
  167.       Index           =   9
  168.       Left            =   120
  169.       TabIndex        =   8
  170.       Top             =   720
  171.       Width           =   2715
  172.    End
  173.    Begin VB.Label Label1 
  174.       Caption         =   "Percent of Memory in Use:"
  175.       BeginProperty Font 
  176.          Name            =   "Verdana"
  177.          Size            =   9
  178.          Charset         =   0
  179.          Weight          =   400
  180.          Underline       =   0   'False
  181.          Italic          =   0   'False
  182.          Strikethrough   =   0   'False
  183.       EndProperty
  184.       Height          =   255
  185.       Index           =   8
  186.       Left            =   120
  187.       TabIndex        =   7
  188.       Top             =   240
  189.       Width           =   2715
  190.    End
  191.    Begin VB.Label Label1 
  192.       Alignment       =   1  'Right Justify
  193.       BeginProperty Font 
  194.          Name            =   "Verdana"
  195.          Size            =   9
  196.          Charset         =   0
  197.          Weight          =   400
  198.          Underline       =   0   'False
  199.          Italic          =   0   'False
  200.          Strikethrough   =   0   'False
  201.       EndProperty
  202.       Height          =   255
  203.       Index           =   6
  204.       Left            =   3030
  205.       TabIndex        =   6
  206.       Top             =   3135
  207.       Width           =   1560
  208.    End
  209.    Begin VB.Label Label1 
  210.       Alignment       =   1  'Right Justify
  211.       BeginProperty Font 
  212.          Name            =   "Verdana"
  213.          Size            =   9
  214.          Charset         =   0
  215.          Weight          =   400
  216.          Underline       =   0   'False
  217.          Italic          =   0   'False
  218.          Strikethrough   =   0   'False
  219.       EndProperty
  220.       Height          =   255
  221.       Index           =   5
  222.       Left            =   3030
  223.       TabIndex        =   5
  224.       Top             =   2655
  225.       Width           =   1560
  226.    End
  227.    Begin VB.Label Label1 
  228.       Alignment       =   1  'Right Justify
  229.       BeginProperty Font 
  230.          Name            =   "Verdana"
  231.          Size            =   9
  232.          Charset         =   0
  233.          Weight          =   400
  234.          Underline       =   0   'False
  235.          Italic          =   0   'False
  236.          Strikethrough   =   0   'False
  237.       EndProperty
  238.       Height          =   255
  239.       Index           =   4
  240.       Left            =   3030
  241.       TabIndex        =   4
  242.       Top             =   2175
  243.       Width           =   1560
  244.    End
  245.    Begin VB.Label Label1 
  246.       Alignment       =   1  'Right Justify
  247.       BeginProperty Font 
  248.          Name            =   "Verdana"
  249.          Size            =   9
  250.          Charset         =   0
  251.          Weight          =   400
  252.          Underline       =   0   'False
  253.          Italic          =   0   'False
  254.          Strikethrough   =   0   'False
  255.       EndProperty
  256.       Height          =   255
  257.       Index           =   3
  258.       Left            =   3030
  259.       TabIndex        =   3
  260.       Top             =   1695
  261.       Width           =   1560
  262.    End
  263.    Begin VB.Label Label1 
  264.       Alignment       =   1  'Right Justify
  265.       BeginProperty Font 
  266.          Name            =   "Verdana"
  267.          Size            =   9
  268.          Charset         =   0
  269.          Weight          =   400
  270.          Underline       =   0   'False
  271.          Italic          =   0   'False
  272.          Strikethrough   =   0   'False
  273.       EndProperty
  274.       Height          =   255
  275.       Index           =   2
  276.       Left            =   3030
  277.       TabIndex        =   2
  278.       Top             =   1215
  279.       Width           =   1560
  280.    End
  281.    Begin VB.Label Label1 
  282.       Alignment       =   1  'Right Justify
  283.       BeginProperty Font 
  284.          Name            =   "Verdana"
  285.          Size            =   9
  286.          Charset         =   0
  287.          Weight          =   400
  288.          Underline       =   0   'False
  289.          Italic          =   0   'False
  290.          Strikethrough   =   0   'False
  291.       EndProperty
  292.       Height          =   255
  293.       Index           =   1
  294.       Left            =   3030
  295.       TabIndex        =   1
  296.       Top             =   735
  297.       Width           =   1560
  298.    End
  299.    Begin VB.Label Label1 
  300.       Alignment       =   1  'Right Justify
  301.       BeginProperty Font 
  302.          Name            =   "Verdana"
  303.          Size            =   9
  304.          Charset         =   0
  305.          Weight          =   400
  306.          Underline       =   0   'False
  307.          Italic          =   0   'False
  308.          Strikethrough   =   0   'False
  309.       EndProperty
  310.       Height          =   255
  311.       Index           =   0
  312.       Left            =   3030
  313.       TabIndex        =   0
  314.       Top             =   255
  315.       Width           =   1560
  316.    End
  317. Attribute VB_Name = "MemStatusForm"
  318. Attribute VB_GlobalNameSpace = False
  319. Attribute VB_Creatable = False
  320. Attribute VB_PredeclaredId = True
  321. Attribute VB_Exposed = False
  322. '  ******************************
  323. '  ******************************
  324. '  ** MASTERING VB6            **
  325. '  ** by Evangelos Petroutos   **
  326. '  ** SYBEX, 1998              **
  327. '  ******************************
  328. '  ******************************
  329. Option Explicit
  330. Private Declare Sub GlobalMemoryStatus Lib "kernel32" (lpBuffer As MEMORYSTATUS)
  331. Private Type MEMORYSTATUS
  332.         dwLength As Long
  333.         dwMemoryLoad As Long
  334.         dwTotalPhys As Long
  335.         dwAvailPhys As Long
  336.         dwTotalPageFile As Long
  337.         dwAvailPageFile As Long
  338.         dwTotalVirtual As Long
  339.         dwAvailVirtual As Long
  340. End Type
  341. Private Sub Command1_Click()
  342. Dim memStat As MEMORYSTATUS
  343.     memStat.dwLength = Len(memStat)
  344.     Call GlobalMemoryStatus(memStat)
  345.     Label1(0).Caption = Format(memStat.dwMemoryLoad, "###,###,###")
  346.     Label1(1).Caption = Format(memStat.dwTotalPhys, "###,###,###")
  347.     Label1(2).Caption = Format(memStat.dwAvailPhys, "###,###,###")
  348.     Label1(3).Caption = Format(memStat.dwTotalPageFile, "###,###,###")
  349.     Label1(4).Caption = Format(memStat.dwAvailPageFile, "###,###,###")
  350.     Label1(5).Caption = Format(memStat.dwTotalVirtual, "###,###,###")
  351.     Label1(6).Caption = Format(memStat.dwAvailVirtual, "###,###,###")
  352.     Label1(7).Caption = Format(memStat.dwTotalVirtual - memStat.dwAvailVirtual, "###,###,###")
  353. End Sub
  354.