我很赞同yms兄的看法。我刚才做了一个类来测试了一下,觉得VB是可以实现类的封装,但继承好象不足。就不谈多态等特性了。以下是我刚才做的用来对windows系统内存状态信息进行管理的类:
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "clsMem"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option Explicit '用来得到windows操作系统的内存状态
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 Declare Sub GlobalMemoryStatus Lib "kernel32" (lpBuffer As MEMORYSTATUS)
Private mvarMem As MEMORYSTATUS
Public Sub SetLength() '设置参数长度
mvarMem.dwLength = Len(mvarMem)
End Sub
Public Sub Update() '获得系统中内存的状态
GlobalMemoryStatus mvarMem
End Sub
Public Function GetLength() As Long
GetLength = mvarMem.dwLength
End Function
Public Function GetAvailPhys() As Long
GetAvailPhys = mvarMem.dwAvailPhys
End Function
Public Function GetTotalPhys() As Long
GetTotalPhys = mvarMem.dwTotalPhys
End Function
Public Function GetAvailPageFile() As Long
GetAvailPageFile = mvarMem.dwAvailPageFile
End Function
Public Function GetTotalPageFile() As Long
GetTotalPageFile = mvarMem.dwTotalPageFile
End Function
Public Function GetAvailVirtual() As Long
GetAvailVirtual = mvarMem.dwAvailVirtual
End Function
Public Function GetTotalVirtual() As Long
GetTotalVirtual = mvarMem.dwTotalVirtual
End Function
Public Function GetMemoryLoad() As Long
GetMemoryLoad = mvarMem.dwMemoryLoad
End Function