home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 5 / MasteringVisualBasic5.iso / ch_code / ch12 / memstat / memstat.frm (.txt) next >
Encoding:
Visual Basic Form  |  1997-02-20  |  4.9 KB  |  168 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Memory Status"
  4.    ClientHeight    =   4605
  5.    ClientLeft      =   60
  6.    ClientTop       =   330
  7.    ClientWidth     =   4935
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   4605
  10.    ScaleWidth      =   4935
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.CommandButton Command1 
  13.       Caption         =   "Memory Status"
  14.       Height          =   615
  15.       Left            =   960
  16.       TabIndex        =   14
  17.       Top             =   3840
  18.       Width           =   2895
  19.    End
  20.    Begin VB.Label Label1 
  21.       Caption         =   "Free Virtual Bytes:"
  22.       Height          =   255
  23.       Index           =   13
  24.       Left            =   120
  25.       TabIndex        =   13
  26.       Top             =   3120
  27.       Width           =   2175
  28.    End
  29.    Begin VB.Label Label1 
  30.       Caption         =   "Total Virtual Bytes:"
  31.       Height          =   255
  32.       Index           =   12
  33.       Left            =   120
  34.       TabIndex        =   12
  35.       Top             =   2640
  36.       Width           =   2175
  37.    End
  38.    Begin VB.Label Label1 
  39.       Caption         =   "Free Byte of Paging File:"
  40.       Height          =   255
  41.       Index           =   11
  42.       Left            =   120
  43.       TabIndex        =   11
  44.       Top             =   2160
  45.       Width           =   2175
  46.    End
  47.    Begin VB.Label Label1 
  48.       Caption         =   "Page File Bytes:"
  49.       Height          =   255
  50.       Index           =   10
  51.       Left            =   120
  52.       TabIndex        =   10
  53.       Top             =   1680
  54.       Width           =   2175
  55.    End
  56.    Begin VB.Label Label1 
  57.       Caption         =   "Available Physical Bytes:"
  58.       Height          =   255
  59.       Index           =   9
  60.       Left            =   120
  61.       TabIndex        =   9
  62.       Top             =   1200
  63.       Width           =   2175
  64.    End
  65.    Begin VB.Label Label1 
  66.       Caption         =   "Total Physical Bytes:"
  67.       Height          =   255
  68.       Index           =   8
  69.       Left            =   120
  70.       TabIndex        =   8
  71.       Top             =   720
  72.       Width           =   2175
  73.    End
  74.    Begin VB.Label Label1 
  75.       Caption         =   "Percent of Memory in Use:"
  76.       Height          =   255
  77.       Index           =   7
  78.       Left            =   120
  79.       TabIndex        =   7
  80.       Top             =   240
  81.       Width           =   2175
  82.    End
  83.    Begin VB.Label Label1 
  84.       Height          =   255
  85.       Index           =   6
  86.       Left            =   2640
  87.       TabIndex        =   6
  88.       Top             =   3120
  89.       Width           =   2175
  90.    End
  91.    Begin VB.Label Label1 
  92.       Height          =   255
  93.       Index           =   5
  94.       Left            =   2640
  95.       TabIndex        =   5
  96.       Top             =   2640
  97.       Width           =   2175
  98.    End
  99.    Begin VB.Label Label1 
  100.       Height          =   255
  101.       Index           =   4
  102.       Left            =   2640
  103.       TabIndex        =   4
  104.       Top             =   2160
  105.       Width           =   2175
  106.    End
  107.    Begin VB.Label Label1 
  108.       Height          =   255
  109.       Index           =   3
  110.       Left            =   2640
  111.       TabIndex        =   3
  112.       Top             =   1680
  113.       Width           =   2175
  114.    End
  115.    Begin VB.Label Label1 
  116.       Height          =   255
  117.       Index           =   2
  118.       Left            =   2640
  119.       TabIndex        =   2
  120.       Top             =   1200
  121.       Width           =   2175
  122.    End
  123.    Begin VB.Label Label1 
  124.       Height          =   255
  125.       Index           =   1
  126.       Left            =   2640
  127.       TabIndex        =   1
  128.       Top             =   720
  129.       Width           =   2175
  130.    End
  131.    Begin VB.Label Label1 
  132.       Height          =   255
  133.       Index           =   0
  134.       Left            =   2640
  135.       TabIndex        =   0
  136.       Top             =   240
  137.       Width           =   2175
  138.    End
  139. Attribute VB_Name = "Form1"
  140. Attribute VB_GlobalNameSpace = False
  141. Attribute VB_Creatable = False
  142. Attribute VB_PredeclaredId = True
  143. Attribute VB_Exposed = False
  144. Option Explicit
  145. Private Declare Sub GlobalMemoryStatus Lib "kernel32" (lpBuffer As MEMORYSTATUS)
  146. Private Type MEMORYSTATUS
  147.         dwLength As Long
  148.         dwMemoryLoad As Long
  149.         dwTotalPhys As Long
  150.         dwAvailPhys As Long
  151.         dwTotalPageFile As Long
  152.         dwAvailPageFile As Long
  153.         dwTotalVirtual As Long
  154.         dwAvailVirtual As Long
  155. End Type
  156. Private Sub Command1_Click()
  157.     Dim memStat As MEMORYSTATUS
  158.     memStat.dwLength = Len(memStat)
  159.     Call GlobalMemoryStatus(memStat)
  160.     Label1(0).Caption = memStat.dwMemoryLoad
  161.     Label1(1).Caption = memStat.dwTotalPhys
  162.     Label1(2).Caption = memStat.dwAvailPhys
  163.     Label1(3).Caption = memStat.dwTotalPageFile
  164.     Label1(4).Caption = memStat.dwAvailPageFile
  165.     Label1(5).Caption = memStat.dwTotalVirtual
  166.     Label1(6).Caption = memStat.dwAvailVirtual
  167. End Sub
  168.