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
#2
Nice! More of those API's.
Reply
#3
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
Reply




Users browsing this thread: 1 Guest(s)