See corrected code below...
Printable View
See corrected code below...
See below...
For those that are interested here is the completed code. If you see anything that does not look right please let me know.
Code:Private Type ULARGE_INTEGER
LowPart As Long
HighPart As Long
End Type
Private Type MEMORY_STATUS
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
' This is needed for the larger memory variables in Windows 2000
Private Type MEMORY_STATUS_EX
dwLength As Long
dwMemoryLoad As Long
ullTotalPhys As ULARGE_INTEGER
ullAvailPhys As ULARGE_INTEGER
ullTotalPageFile As ULARGE_INTEGER
ullAvailPageFile As ULARGE_INTEGER
ullTotalVirtual As ULARGE_INTEGER
ullAvailVirtual As ULARGE_INTEGER
ullAvailExtendedVirtual As ULARGE_INTEGER
End Type
Private Declare Function GlobalMemoryStatusEx Lib "kernel32.dll" (lpBuffer As MEMORY_STATUS_EX) As Long
Private Declare Sub GlobalMemoryStatus Lib "kernel32.dll" (lpBuffer As MEMORY_STATUS)
Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public Function MemoryInfo() As String
Dim AvailMem As String
Dim AvailPageMem As String
Dim AvailVirtualMem As String
Dim LoadMem As String
Dim PageMem As String
Dim PhysicalMem As String
Dim VirtualMem As String
' pseudo-64-bit integer buffer we need this just so we can get a proper 64 bit storage space
Dim MemTemp As Currency
Dim Info As String
Dim MiscClass As SLPStdMisc
Dim MSWin9XNT As MEMORY_STATUS
Dim MSWin2000 As MEMORY_STATUS_EX
Set MiscClass = New SLPStdMisc
If MiscClass.GetOSVersion <> "Win2000" Then
MSWin9XNT.dwLength = Len(MSWin9XNT)
GlobalMemoryStatus MSWin9XNT
AvailMem = MSWin9XNT.dwAvailPhys
AvailPageMem = MSWin9XNT.dwAvailPageFile
AvailVirtualMem = MSWin9XNT.dwAvailVirtual
LoadMem = MSWin9XNT.dwMemoryLoad
PageMem = MSWin9XNT.dwTotalPageFile
PhysicalMem = MSWin9XNT.dwTotalPhys
VirtualMem = MSWin9XNT.dwTotalVirtual
Me.lblrTotalPhysicalMemory.Caption = _
Format$(PhysicalMem \ 1024, "###,###,###") & "K"
Me.lblrAvailablePhysicalMemory.Caption = _
Format$(AvailMem \ 1024, "###,###,###") & "K"
Me.lblrPercentageMemoryInUse.Caption = _
LoadMem & "%"
Me.lblrMaximumPagingFileSize.Caption = _
Format$(PageMem \ 1024, "###,###,###") & "K"
Me.lblrKilobytesAvailableInPagingFile.Caption = _
Format$(AvailPageMem \ 1024, "###,###,###") & "K"
Me.lblrTotalVirtualMemory.Caption = _
Format$(VirtualMem \ 1024, "###,###,###") & "K"
Me.lblrAvailableVirtualMemory.Caption = _
Format$(AvailVirtualMem \ 1024, "###,###,###") & "K"
Else
MSWin2000.dwLength = Len(MSWin2000)
Call GlobalMemoryStatusEx(MSWin2000)
CopyMemory MemTemp, MSWin2000.ullAvailPhys, Len(MemTemp)
AvailMem = Str(MemTemp)
CopyMemory MemTemp, MSWin2000.ullAvailPageFile, Len(MemTemp)
AvailPageMem = Str(MemTemp)
CopyMemory MemTemp, MSWin2000.ullAvailVirtual, Len(MemTemp)
AvailVirtualMem = Str(MemTemp)
LoadMem = Str(MSWin2000.dwMemoryLoad)
CopyMemory MemTemp, MSWin2000.ullTotalPageFile, Len(MemTemp)
PageMem = Str(MemTemp)
CopyMemory MemTemp, MSWin2000.ullTotalPhys, Len(MemTemp)
PhysicalMem = Str(MemTemp)
CopyMemory MemTemp, MSWin2000.ullTotalVirtual, Len(MemTemp)
VirtualMem = Str(MemTemp)
Me.lblrTotalPhysicalMemory.Caption = _
Format$(PhysicalMem * (10000 / 1024), "###,###,###") & "K"
Me.lblrAvailablePhysicalMemory.Caption = _
Format$(AvailMem * (10000 / 1024), "###,###,###") & "K"
Me.lblrPercentageMemoryInUse.Caption = _
LoadMem & "%"
Me.lblrMaximumPagingFileSize.Caption = _
Format$(PageMem * (10000 / 1024), "###,###,###") & "K"
Me.lblrKilobytesAvailableInPagingFile.Caption = _
Format$(AvailPageMem * (10000 / 1024), "###,###,###") & "K"
Me.lblrTotalVirtualMemory.Caption = _
Format$(VirtualMem * (10000 / 1024), "###,###,###") & "K"
Me.lblrAvailableVirtualMemory.Caption = _
Format$(AvailVirtualMem * (10000 / 1024), "###,###,###") & "K"
End If
End Function