|
3 | 3 |  |
4 | 4 |  |
5 | 5 |
|
| 6 | +[](https://www.nuget.org/packages/OpenHardwareMonitorLib/) |
| 7 | +[](https://www.nuget.org/packages/OpenHardwareMonitorLib/) |
| 8 | + |
6 | 9 | Open hardware monitor - is free software that can monitor the temperature sensors, fan speeds, voltages, load and clock speeds of your computer. |
7 | 10 |
|
8 | 11 | This application is based on the "original" [openhardwaremonitor](https://github.com/openhardwaremonitor/openhardwaremonitor) project. |
@@ -59,6 +62,63 @@ You can see information about devices such as: |
59 | 62 | **or download build from [releases](https://github.com/sergiye/openhardwaremonitor/releases).** |
60 | 63 |
|
61 | 64 |
|
| 65 | +# Developer information |
| 66 | +**Integrate the library in own application** |
| 67 | +1. Add the [OpenHardwareMonitorLib](https://www.nuget.org/packages/OpenHardwareMonitorLib/) NuGet package to your application. |
| 68 | +2. Use the sample code below. |
| 69 | + |
| 70 | + |
| 71 | +**Sample code** |
| 72 | +```c# |
| 73 | +public class UpdateVisitor : IVisitor { |
| 74 | + public void VisitComputer(IComputer computer) { |
| 75 | + computer.Traverse(this); |
| 76 | + } |
| 77 | + public void VisitHardware(IHardware hardware) { |
| 78 | + hardware.Update(); |
| 79 | + foreach (IHardware subHardware in hardware.SubHardware) subHardware.Accept(this); |
| 80 | + } |
| 81 | + public void VisitSensor(ISensor sensor) { } |
| 82 | + public void VisitParameter(IParameter parameter) { } |
| 83 | +} |
| 84 | + |
| 85 | +public void Monitor() { |
| 86 | + Computer computer = new Computer { |
| 87 | + IsCpuEnabled = true, |
| 88 | + IsGpuEnabled = true, |
| 89 | + IsMemoryEnabled = true, |
| 90 | + IsMotherboardEnabled = true, |
| 91 | + IsControllerEnabled = true, |
| 92 | + IsNetworkEnabled = true, |
| 93 | + IsStorageEnabled = true |
| 94 | + }; |
| 95 | + |
| 96 | + computer.Open(); |
| 97 | + computer.Accept(new UpdateVisitor()); |
| 98 | + |
| 99 | + foreach (IHardware hardware in computer.Hardware) { |
| 100 | + Console.WriteLine("Hardware: {0}", hardware.Name); |
| 101 | + foreach (IHardware subhardware in hardware.SubHardware) { |
| 102 | + Console.WriteLine("\tSubhardware: {0}", subhardware.Name); |
| 103 | + foreach (ISensor sensor in subhardware.Sensors) { |
| 104 | + Console.WriteLine("\t\tSensor: {0}, value: {1}", sensor.Name, sensor.Value); |
| 105 | + } |
| 106 | + } |
| 107 | + |
| 108 | + foreach (ISensor sensor in hardware.Sensors) { |
| 109 | + Console.WriteLine("\tSensor: {0}, value: {1}", sensor.Name, sensor.Value); |
| 110 | + } |
| 111 | + } |
| 112 | + |
| 113 | + computer.Close(); |
| 114 | +} |
| 115 | +``` |
| 116 | + |
| 117 | +**Administrator rights** |
| 118 | + |
| 119 | +Some sensors require administrator privileges to access the data. Restart your IDE with admin privileges, or add an [app.manifest](https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests) file to your project with requestedExecutionLevel on requireAdministrator. |
| 120 | + |
| 121 | + |
62 | 122 | ## How can I help improve it? |
63 | 123 | The OpenHardwareMonitor team welcomes feedback and contributions!<br/> |
64 | 124 | You can check if it works properly on your motherboard. For many manufacturers, the way of reading data differs a bit, so if you notice any inaccuracies, please send us a pull request. If you have any suggestions or improvements, don't hesitate to create an issue. |
|
0 commit comments