VB 简易教程
您的位置
VB简易教程
 
在线教程
DELPHI语言教程
其它语言
编程技巧
 

用自己的'PROGRAM'测试自己的电脑

大庆采油六厂工艺研究所
王兵 王波 吴莉华

---- 相信大家一定用过许多测试软件,来了解电脑的配置。其实如果你了解Windows API函数的话,你完全可以自己动手编程来完成上述工作。(以下程序是用VB5.0编写)

---- 1.测试CPU类型

---- 使用GetSystemInfo API函数可以测试CPU类型,而且还能知道当前系统的处理器个数。

Option Explicit
Private Type CPU_Type
  a As Long
  b As Long
  c As Long
  d As Long
  Processormask As Long
  Number_of_Processors As Long
  ProcessorType As Long
  e As Long
  f As Long
End Type
Private Declare Sub GetSystemInfo 
Lib "kernel32" (CPUinfo As CPU_Type)
Private Sub Form_Click()
   Dim CPU As CPU_Type
   GetSystemInfo CPU
   Print "CPU类型为:";CPU.ProcessorType
   Print "CPU个数:";CPU.Number_of_Processors
End Sub
---- 2.测试驱动器类型

---- 用GetDriverType API函数来确定用户计算机驱动器类型

Option Explicit
Private Declare Function GetDriveType Lib
 "kernel32" Alias "GetDriveTypeA" 
(ByVal drive_ As String) As Long 
Private Sub Form_Click()
   DIM  PF$,drv,i
   For i = 0 To 25     '
所有可能的驱动器个数 A: 到 Z:
       PF = Chr$(i + 65) & ":"
       drv = GetDriveType(PF)
       Select Case drv
         Case 2
     Print "驱动器" & PF & "is removable"
         Case 3
           Print "驱动器" & PF & "is fixed"
         Case 4
           Print "驱动器" & PF & "is remote"
         Case 5
           Print "驱动器" & PF & "CD-ROM"
         Case 6
           Print "驱动器" & PF & "is RAM disk"
         Case Else
       End Select
       Next
End Sub
---- 3.用SysInfo控件测试操作系统的版本
Option Explicit
Private Sub Form_Click()
   Dim mm$
Select Case  SysInfo1.OSPlatform
    Case 0
      mm="不能确认"
    Case 1
mm="Windows 95"  &  CStr(SysInfo1.OSVersion) & "版本"
    Case 2
mm="Windows NT"  &  CStr(SysInfo1.OSVersion) & "版本"
End Select 
Print mm
    End Sub
---- 本人用上述API函数功能测得的结果如图示(略)。

---- 以上程序在联想 586上调试通过,2000年1月20日编写。