Menu

#1 Memory Information

open
nobody
1
2008-04-26
2008-04-26
No

wrong procedure:

Module name: mdlPerformance (mdlPerformance.bas)
'===========
'Code option
'===========
Option Explicit

'================
'API declarations
'================
Private Declare Sub GlobalMemoryStatus Lib _
"kernel32" (lpBuffer As MEMORYSTATUS)

'===================================
'Types and enumerations declarations
'===================================
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

'======================
'Get memory information
'======================
Public Sub MemoryInfo(lAPageFile As Label, lAPhys As Label, _
lAVirtual As Label, lTPageFile As Label, lTPhys As Label, _
lTVirtual As Label, lMemUsage As Label)
Dim MemStat As MEMORYSTATUS
MemStat.dwLength = Len(MemStat)
GlobalMemoryStatus MemStat
lAPageFile.Caption = Format(MemStat.dwAvailPageFile _
/ 1024, "###,###,###") & " KB"
lAPhys.Caption = Format(MemStat.dwAvailPhys / 1024, _
"###,###,###") & " KB"
lAVirtual.Caption = Format(MemStat.dwAvailVirtual / _
1024, "###,###,###") & " KB"
lTPageFile.Caption = Format(MemStat.dwTotalPageFile _
/ 1024, "###,###,###") & " KB"
lTPhys.Caption = Format(MemStat.dwTotalPhys / 1024, _
"###,###,###") & " KB"
lTVirtual.Caption = Format(MemStat.dwTotalVirtual / _
1024, "###,###,###") & " KB"
lMemUsage.Caption = MemStat.dwMemoryLoad & " %"
End Sub

Bug:
Form name: frmMain (frmMain.frm)
'===================================
'Show memory information & cpu usage
'===================================
Private Sub tmrMemory_Timer()
MemoryInfo lblMem(0), lblMem(1), lblMem(2), _
lblMem(3), lblMem(4), lblMem(5), lblMem(6)
UpdateValues lblMem(7)
End Sub
[/code]

Fix:
'===================================
'Show memory information & cpu usage
'===================================
Private Sub tmrMemory_Timer()
MemoryInfo lblMem(5), lblMem(1), lblMem(3), _
lblMem(4), lblMem(0), lblMem(2), lblMem(6)
UpdateValues lblMem(7)
End Sub

Discussion


Log in to post a comment.