Skip to content

Instantly share code, notes, and snippets.

@AeroNotix
Created March 23, 2012 16:52
Show Gist options
  • Select an option

  • Save AeroNotix/2172714 to your computer and use it in GitHub Desktop.

Select an option

Save AeroNotix/2172714 to your computer and use it in GitHub Desktop.
from ctypes import (windll, Structure, byref, POINTER,
c_char, c_ubyte, c_bool, c_uint, c_float)
import time
class CTSharedData(Structure):
_fields_ = [
("uiLoad", c_uint * 256),
("uiTjMax", c_uint * 128),
("uiCoreCnt", c_uint),
("uiCPUCnt", c_uint),
("fTemp", c_float * 256),
("fVID", c_float),
("fCPUSpeed", c_float),
("fFSBSpeed", c_float),
("fMultiplier", c_float),
("sCPUName", c_char * 100),
("ucFahrenheit", c_ubyte),
("ucDeltaToTjMax", c_ubyte)]
dll_file = 'path/to/dll'
ctlib = windll.LoadLibrary(dll_file)
get_ctinfo = ctlib.fnGetCoreTempInfoAlt
get_ctinfo.argtypes = [POINTER(CTSharedData)]
get_ctinfo.restype = c_bool
data = CTSharedData()
while (1):
if get_ctinfo(byref(data)):
print("Core temperatures:")
unit = 'F' if data.ucFahrenheit else 'C'
core_temps = data.fTemp[:data.uiCoreCnt]
for core, temp in enumerate(core_temps):
print(" Core {0}: {1:.2f} {2}".format(core, temp, unit))
else:
print('Error accessing Core Temp')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment