GetPhysicallyInstalledSystemMemory
#1
The below snippet will show the amount of RAM your computer currently has installed.

Code: (Select All)
Option Explicit
$NoPrefix
$Console:Only

Const KILOBYTE = 1024
Const MEGABYTE = 1024 ^ 2
Const GIGABYTE = 1024 ^ 3
Const TERABYTE = 1024 ^ 4

Declare Dynamic Library "Kernel32"
    Sub GetPhysicallyInstalledSystemMemory (ByVal TotalMemoryInKilobytes As Offset)
End Declare

Dim As Unsigned Integer64 memory
GetPhysicallyInstalledSystemMemory Offset(memory)

memory = memory * KILOBYTE

Select Case memory
    Case Is < KILOBYTE
        Print Using "   ####  B"; memory
    Case Is < (MEGABYTE) And memory >= KILOBYTE
        Print Using "####.## KB"; (memory / KILOBYTE)
    Case Is < (GIGABYTE) And memory >= (MEGABYTE)
        Print Using "####.## MB"; (memory / (MEGABYTE))
    Case Is < (TERABYTE) And memory >= (GIGABYTE)
        Print Using "####.## GB"; (memory / (GIGABYTE))
End Select
Ask me about Windows API and maybe some Linux stuff
Reply


Messages In This Thread
GetPhysicallyInstalledSystemMemory - by SpriggsySpriggs - 09-09-2022, 07:55 PM
RE: GetPhysicallyInstalledSystemMemory - by Pete - 09-12-2022, 02:14 AM



Users browsing this thread: 1 Guest(s)