practice8-11.frm

来自「深圳大学的vb上机与教学的课件」· FRM 代码 · 共 267 行

FRM
267
字号
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "系统信息"
   ClientHeight    =   5655
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   3510
   LinkTopic       =   "Form1"
   ScaleHeight     =   5655
   ScaleWidth      =   3510
   StartUpPosition =   2  '屏幕中心
   Begin VB.Frame Frame4 
      Caption         =   "磁盘"
      Height          =   735
      Left            =   240
      TabIndex        =   20
      Top             =   4680
      Width           =   3015
      Begin VB.Label Label18 
         Caption         =   "C盘可用空间:"
         Height          =   255
         Left            =   120
         TabIndex        =   23
         Top             =   360
         Width           =   1215
      End
      Begin VB.Label Label19 
         Caption         =   "Label19"
         Height          =   255
         Left            =   1440
         TabIndex        =   22
         Top             =   360
         Width           =   975
      End
      Begin VB.Label Label20 
         Caption         =   "G"
         Height          =   255
         Left            =   2520
         TabIndex        =   21
         Top             =   360
         Width           =   255
      End
   End
   Begin VB.Frame Frame3 
      Caption         =   "CPU"
      Height          =   1095
      Left            =   240
      TabIndex        =   15
      Top             =   3240
      Width           =   3015
      Begin VB.Label Label14 
         Caption         =   "CPU类型:"
         Height          =   255
         Left            =   240
         TabIndex        =   19
         Top             =   360
         Width           =   975
      End
      Begin VB.Label Label15 
         Caption         =   "CPU数量:"
         Height          =   255
         Left            =   240
         TabIndex        =   18
         Top             =   720
         Width           =   855
      End
      Begin VB.Label Label16 
         Caption         =   "Label16"
         Height          =   255
         Left            =   1440
         TabIndex        =   17
         Top             =   360
         Width           =   1335
      End
      Begin VB.Label Label17 
         Caption         =   "Label17"
         Height          =   255
         Left            =   1440
         TabIndex        =   16
         Top             =   720
         Width           =   1215
      End
   End
   Begin VB.Frame Frame2 
      Caption         =   "系统内存"
      Height          =   1455
      Left            =   240
      TabIndex        =   1
      Top             =   1560
      Width           =   3015
      Begin VB.Label Label13 
         Caption         =   "Label13"
         Height          =   255
         Left            =   1320
         TabIndex        =   14
         Top             =   1080
         Width           =   735
      End
      Begin VB.Label Label12 
         Caption         =   "Label12"
         Height          =   255
         Left            =   1320
         TabIndex        =   13
         Top             =   720
         Width           =   735
      End
      Begin VB.Label Label11 
         Caption         =   "Label11"
         Height          =   255
         Left            =   1320
         TabIndex        =   12
         Top             =   360
         Width           =   615
      End
      Begin VB.Label Label10 
         Caption         =   "兆"
         Height          =   255
         Left            =   2280
         TabIndex        =   11
         Top             =   1080
         Width           =   375
      End
      Begin VB.Label Label9 
         Caption         =   "兆"
         Height          =   255
         Left            =   2280
         TabIndex        =   10
         Top             =   720
         Width           =   375
      End
      Begin VB.Label Label8 
         Caption         =   "兆"
         Height          =   255
         Left            =   2280
         TabIndex        =   9
         Top             =   360
         Width           =   375
      End
      Begin VB.Label Label7 
         Caption         =   "虚拟内存:"
         Height          =   255
         Left            =   240
         TabIndex        =   8
         Top             =   1080
         Width           =   1095
      End
      Begin VB.Label Label6 
         Caption         =   "可用内存:"
         Height          =   255
         Left            =   240
         TabIndex        =   7
         Top             =   720
         Width           =   975
      End
      Begin VB.Label Label5 
         Caption         =   "内存总量:"
         Height          =   255
         Left            =   240
         TabIndex        =   6
         Top             =   360
         Width           =   975
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "屏幕分辨率"
      Height          =   1215
      Left            =   240
      TabIndex        =   0
      Top             =   240
      Width           =   3015
      Begin VB.Label Label4 
         Caption         =   "Label4"
         Height          =   255
         Left            =   1800
         TabIndex        =   5
         Top             =   720
         Width           =   855
      End
      Begin VB.Label Label3 
         Caption         =   "Label3"
         Height          =   255
         Left            =   1800
         TabIndex        =   4
         Top             =   360
         Width           =   975
      End
      Begin VB.Label Label2 
         Caption         =   "垂直分辨率:"
         Height          =   255
         Left            =   240
         TabIndex        =   3
         Top             =   720
         Width           =   1215
      End
      Begin VB.Label Label1 
         Caption         =   "水平分辨率:"
         Height          =   255
         Left            =   240
         TabIndex        =   2
         Top             =   360
         Width           =   1215
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'声明类型
Private Type MEMORYSTATUS
        dwLength As Long
        dwMemoryLoad As Long
        dwTotalPhys As Long
        dwAvailPhys As Long
        dwTotalPageFile As Long
        dwAvailPageFile As Long
        dwTotalVirtual As Long
        dwAvailVirtual As Long
End Type
Private Type SYSTEM_INFO
        dwOemID As Long
        dwPageSize As Long
        lpMinimumApplicationAddress As Long
        lpMaximumApplicationAddress As Long
        dwActiveProcessorMask As Long
        dwNumberOrfProcessors As Long
        dwProcessorType As Long
        dwAllocationGranularity As Long
        dwReserved As Long
End Type


'声明函数/过程
Private Declare Function GetSystemMetrics Lib "user32" _
        (ByVal nIndex As Long) As Long
Private Declare Sub GlobalMemoryStatus Lib "kernel32" _
        (lpBuffer As MEMORYSTATUS)
Private Declare Sub GetSystemInfo Lib "kernel32" (lpSystemInfo As SYSTEM_INFO)
Private Declare Function GetDiskFreeSpace Lib "kernel32" Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, lpSectorsPerCluster As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTotalNumberOfClusters As Long) As Long
        
'声明常量
Const SM_CXSCREEN = 0
Const SM_CYSCREEN = 1
Dim meminfo As MEMORYSTATUS
Dim cpuinfo As SYSTEM_INFO
Dim myRootPathName As String, mySectorsPerCluster As Long, myBytesPerSector As Long, myNumberOfFreeClusters As Long, myTotalNumberOfClusters As Long

Private Sub Form_Load()
  '获得屏幕的分辨率
  x = GetSystemMetrics(SM_CXSCREEN)
  y = GetSystemMetrics(SM_CYSCREEN)
  Label3.Caption = x
  Label4.Caption = y
  '获得内存信息
  Call GlobalMemoryStatus(meminfo)
  Label11.Caption = Int(meminfo.dwTotalPhys / 1024 / 1024)
  Label12.Caption = Int(meminfo.dwAvailPhys / 1024 / 1024)
  Label13.Caption = Int(meminfo.dwTotalVirtual / 1024 / 1024)
  '获得CPU信息
  Call GetSystemInfo(cpuinfo)
  Label16.Caption = cpuinfo.dwProcessorType
  Label17.Caption = cpuinfo.dwNumberOrfProcessors
  Call GetDiskFreeSpace("c:\", mySectorsPerCluster, myBytesPerSector, myNumberOfFreeClusters, myTotalNumberOfClusters)
  Label19.Caption = Int(mySectorsPerCluster * myBytesPerSector / 1024 / 1024 * myNumberOfFreeClusters)
End Sub

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?