
Finding info about a process, like Process Viewer/Viewer, WinTop
Quote:
>How can I get CPU %, memory usage, and other useful stuff like that?
>Thanks,
>--
>Bodi Klamph
>Azure Dragon Software
Bodi,
This should get you started on getting Memory Info:
Place the code below in a class:
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 mMS As MEMORYSTATUS
Private mMemoryUsed As Long
Private mTotalPhysicalMemory As Long
Private mAvailablePhysicalMemory As Long
Private mTotalPagingFile As Long
Private mAvailablePagingFile As Long
Private mPercentageDriveUsed As Single
Private mTotalBytes As Long
Private mBytesFreeToCaller As Long
Private mTotalFreeBytes As Long
Public Sub GetStatus()
mMS.dwLength = Len(mMS)
GlobalMemoryStatus mMS
'fill properties
mMemoryUsed = mMS.dwMemoryLoad
mTotalPhysicalMemory = mMS.dwTotalPhys
mAvailablePhysicalMemory = mMS.dwAvailPhys
mTotalPagingFile = mMS.dwTotalPageFile
mAvailablePagingFile = mMS.dwAvailPageFile
End Sub
Now just create properties to expose the private members...
Public Property Get MemoryUsed() As Long
MemoryUsed = mMemoryUsed
End Property
Public Property Get TotalPhysicalMemory() As Long
TotalPhysicalMemory = mTotalPhysicalMemory
End Property
Public Property Get AvailablePhysicalMemory() As Long
AvailablePhysicalMemory = mAvailablePhysicalMemory
End Property
Public Property Get TotalPagingFile() As Long
TotalPagingFile = mTotalPagingFile
End Property
Public Property Get AvailablePagingFile() As Long
AvailablePagingFile = mAvailablePagingFile
End Property
The values are returned in bytes...
(You don't have to create a class to do this. It's just that I've already
created a class just for this and
kinda copied and pasted to answer your question)
Hasta Luego
am
To send me email remove the zzz (s) from the email address
Do not click the Reply button