Advertisement
Snuggledash

available_ram.py

Jun 21st, 2020
1,161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. import locale, ctypes, struct
  2. MEMORYSTATUSEX_SIZE = 64
  3. MB_ICONINFORMATION = 0x40
  4.  
  5. locale.setlocale(locale.LC_NUMERIC, "")
  6.  
  7. buf = ctypes.create_string_buffer(MEMORYSTATUSEX_SIZE)
  8. buf[0:4] = struct.pack("I", MEMORYSTATUSEX_SIZE)
  9. if ctypes.windll.kernel32.GlobalMemoryStatusEx(buf):
  10.     (memory_load,
  11.     total_phys,
  12.     avail_phys,
  13.     total_pagefile,
  14.     avail_pagefile,
  15.     total_virtual,
  16.     avail_virtual,
  17.     avail_extended_virtual) = struct.unpack("xxxxIQQQQQQQ", buf)
  18.     msg = locale.format_string("%d Bytes frei", avail_phys, grouping=True)
  19.     ctypes.windll.user32.MessageBoxW(None, msg, "Info", MB_ICONINFORMATION)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement