Skip to content

Commit

Permalink
Add HidSharp.dll, add test program for LibreHardwareMonitor
Browse files Browse the repository at this point in the history
  • Loading branch information
mathoudebine committed Dec 9, 2022
1 parent 497d25e commit a67b154
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
Binary file added external/LibreHardwareMonitor/HidSharp.dll
Binary file not shown.
56 changes: 56 additions & 0 deletions external/LibreHardwareMonitor/test_librehardwaremonitor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Use this file to display all hardware & sensors available from LibreHardwareMonitor on your computer
# Windows only - needs administrative rights
import ctypes
import sys
import clr
import os
from win32api import *

if ctypes.windll.shell32.IsUserAnAdmin() == 0:
print("Program is not running as administrator. Please run with admin rights or choose another HW_SENSORS option "
"in config.yaml")
try:
sys.exit(0)
except:
os._exit(0)

# noinspection PyUnresolvedReferences
clr.AddReference(os.getcwd() + '\\LibreHardwareMonitorLib.dll')
# noinspection PyUnresolvedReferences
clr.AddReference(os.getcwd() + '\\HidSharp.dll')
# noinspection PyUnresolvedReferences
from LibreHardwareMonitor import Hardware

File_information = GetFileVersionInfo(os.getcwd() + '\\LibreHardwareMonitorLib.dll', "\\")
ms_file_version = File_information['FileVersionMS']
ls_file_version = File_information['FileVersionLS']
print("Found LibreHardwareMonitorLib %s" % ".".join([str(HIWORD(ms_file_version)), str(LOWORD(ms_file_version)),
str(HIWORD(ls_file_version)),
str(LOWORD(ls_file_version))]))

File_information = GetFileVersionInfo(os.getcwd() + '\\HidSharp.dll', "\\")
ms_file_version = File_information['FileVersionMS']
ls_file_version = File_information['FileVersionLS']
print("Found HidSharp %s" % ".".join([str(HIWORD(ms_file_version)), str(LOWORD(ms_file_version)),
str(HIWORD(ls_file_version)),
str(LOWORD(ls_file_version))]))

handle = Hardware.Computer()
handle.IsCpuEnabled = True
handle.IsGpuEnabled = True
handle.IsMemoryEnabled = True
handle.IsMotherboardEnabled = True
handle.IsControllerEnabled = True
handle.IsNetworkEnabled = True
handle.IsStorageEnabled = True
handle.Open()

for hw in handle.Hardware:
print("%s | %s | %s" % (hw.HardwareType, hw.Name, hw.Identifier))
hw.Update()

for sensor in hw.Sensors:
print(" %s | %s | %s" % (sensor.SensorType, sensor.Name, sensor.Value))
print("----------------------------------------------------")

handle.Close()
2 changes: 2 additions & 0 deletions library/sensors/sensors_librehardwaremonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# noinspection PyUnresolvedReferences
clr.AddReference(lhm_dll)
# noinspection PyUnresolvedReferences
clr.AddReference(os.getcwd() + '\\external\\LibreHardwareMonitor\\HidSharp.dll')
# noinspection PyUnresolvedReferences
from LibreHardwareMonitor import Hardware

File_information = GetFileVersionInfo(lhm_dll, "\\")
Expand Down

0 comments on commit a67b154

Please sign in to comment.