QB64 Phoenix Edition
GetPhysicallyInstalledSystemMemory - Printable Version

+- QB64 Phoenix Edition (https://staging.qb64phoenix.com)
+-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1)
+--- Forum: Expanding Horizons (Libraries) (https://staging.qb64phoenix.com/forumdisplay.php?fid=21)
+---- Forum: Spriggsy (https://staging.qb64phoenix.com/forumdisplay.php?fid=30)
+---- Thread: GetPhysicallyInstalledSystemMemory (/showthread.php?tid=873)



GetPhysicallyInstalledSystemMemory - SpriggsySpriggs - 09-09-2022

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



RE: GetPhysicallyInstalledSystemMemory - BDS107 - 09-10-2022

Nice! More of those API's.


RE: GetPhysicallyInstalledSystemMemory - Pete - 09-12-2022

I tried to sacrifice some ram for more memory once, but the priest chased me off the alter before I finished the job. Oh well, 4K's better than nothing. Waiting on Steve to say, "Ewe, Pete made a baaaaad joke."

Pete