home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 October / maximum-cd-2011-10.iso / DiscContents / digsby_setup.exe / lib / gui / native / win / winsysinfo.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2011-06-22  |  3.8 KB  |  95 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. import os
  5. import ctypes
  6. from ctypes import c_ulong, c_ulonglong, c_void_p, byref, POINTER, windll
  7. from ctypes.wintypes import DWORD, WORD
  8. kernel32 = windll.kernel32
  9. DWORD_PTR = POINTER(DWORD)
  10.  
  11. class SYSTEM_INFO(ctypes.Structure):
  12.     _fields_ = [
  13.         ('dwOemId', DWORD),
  14.         ('dwPageSize', DWORD),
  15.         ('lpMinimumApplicationAddress', c_void_p),
  16.         ('lpMaximumApplicationAddress', c_void_p),
  17.         ('dwActiveProcessorMask', DWORD_PTR),
  18.         ('dwNumberOfProcessors', DWORD),
  19.         ('dwProcessorType', DWORD),
  20.         ('dwAllocationGranularity', DWORD),
  21.         ('wProcessorLevel', WORD),
  22.         ('wProcessorRevision', WORD)]
  23.  
  24.  
  25. class MEMORYSTATUS(ctypes.Structure):
  26.     _fields_ = [
  27.         ('dwLength', c_ulong),
  28.         ('dwMemoryLoad', c_ulong),
  29.         ('dwTotalPhys', c_ulong),
  30.         ('dwAvailPhys', c_ulong),
  31.         ('dwTotalPageFile', c_ulong),
  32.         ('dwAvailPageFile', c_ulong),
  33.         ('dwTotalVirtual', c_ulong),
  34.         ('dwAvailVirtual', c_ulong)]
  35.  
  36. DWORDLONG = c_ulonglong
  37.  
  38. class MEMORYSTATUSEX(ctypes.Structure):
  39.     _fields_ = [
  40.         ('dwLength', DWORD),
  41.         ('dwMemoryLoad', DWORD),
  42.         ('ullTotalPhys', DWORDLONG),
  43.         ('ullAvailPhys', DWORDLONG),
  44.         ('ullTotalPageFile', DWORDLONG),
  45.         ('ullAvailPageFile', DWORDLONG),
  46.         ('ullTotalVirtual', DWORDLONG),
  47.         ('ullAvailVirtual', DWORDLONG),
  48.         ('ullAvailExtendedVirtual', DWORDLONG)]
  49.  
  50.  
  51. try:
  52.     GetSystemInfo = kernel32.GetSystemInfo
  53. except ImportError:
  54.     pass
  55.  
  56.  
  57. def get_num_processors():
  58.     info = SYSTEM_INFO()
  59.     GetSystemInfo(byref(info))
  60.     return info.dwNumberOfProcessors
  61.  
  62.  
  63. class SystemInformation(object):
  64.     
  65.     def _ram(self):
  66.         kernel32 = ctypes.windll.kernel32
  67.         memoryStatus = MEMORYSTATUS()
  68.         memoryStatus.dwLength = ctypes.sizeof(MEMORYSTATUS)
  69.         kernel32.GlobalMemoryStatus(ctypes.byref(memoryStatus))
  70.         ret = (dict,)((lambda .0: for k, _type in .0:
  71. (k, getattr(memoryStatus, k)))(MEMORYSTATUS._fields_))
  72.         ret.update(self._ramex())
  73.         return ret
  74.  
  75.     
  76.     def _ramex(self):
  77.         kernel32 = ctypes.windll.kernel32
  78.         memoryStatus = MEMORYSTATUSEX()
  79.         memoryStatus.dwLength = ctypes.sizeof(MEMORYSTATUSEX)
  80.         kernel32.GlobalMemoryStatusEx(ctypes.byref(memoryStatus))
  81.         return (dict,)((lambda .0: for k, _type in .0:
  82. (k, getattr(memoryStatus, k)))(MEMORYSTATUSEX._fields_))
  83.  
  84.     
  85.     def _disk_c(self):
  86.         drive = unicode(os.getenv('SystemDrive'))
  87.         freeuser = ctypes.c_int64()
  88.         total = ctypes.c_int64()
  89.         free = ctypes.c_int64()
  90.         ctypes.windll.kernel32.GetDiskFreeSpaceExW(drive, ctypes.byref(freeuser), ctypes.byref(total), ctypes.byref(free))
  91.         d = dict(drive = drive, freeuser = freeuser.value, total = total.value, free = free.value)
  92.         return d
  93.  
  94.  
  95.