Code: Select all
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
using OpenHardwareMonitor.Hardware;
using OpenHardwareMonitor.Collections;
using OpenHardwareMonitor;
using GetCoreTempInfoNET;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
System.Timers.Timer RefreshInfo;
CoreTempInfo CTInfo;
public Form1()
{
InitializeComponent();
CTInfo = new CoreTempInfo();
//Sign up for an event reporting errors
CTInfo.ReportError += new ErrorOccured(CTInfo_ReportError);
//Initiate a Timer.
RefreshInfo = new System.Timers.Timer();
RefreshInfo.Interval = 1000;
RefreshInfo.Elapsed += new System.Timers.ElapsedEventHandler(RefreshInfo_Elapsed);
//Get info manually.
RefreshInfo_Elapsed(null, null);
//Start Timer counter.
RefreshInfo.Start();
//Press return to exit.
Console.ReadLine();
//Kill the timer/
RefreshInfo.Stop();
RefreshInfo.Dispose();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void RefreshInfo_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
//Clear the screen and post the title.
//Console.Clear();
//Console.WriteLine("Core Temp shared memory reader:\n");
label1.Text = "Core Temp shared memory reader:\n";
//Attempt to read shared memory.
bool bReadSuccess = CTInfo.GetData();
//If read was successful the post the new info on the console.
if (bReadSuccess)
{
uint index;
char TempType;
if (CTInfo.IsFahrenheit)
TempType = 'F';
else
TempType = 'C';
label2.Text = "CPU Name: " + CTInfo.GetCPUName;
label3.Text = "CPU Speed: " + CTInfo.GetCPUSpeed + "MHz (" + CTInfo.GetFSBSpeed + " x " + CTInfo.GetMultiplier + ")";
label4.Text = "CPU VID: " + CTInfo.GetVID + "v";
label5.Text = "Physical CPUs: " + CTInfo.GetCPUCount;
label6.Text = "Cores per CPU: " + CTInfo.GetCoreCount;
for (uint i = 0; i < CTInfo.GetCPUCount; i++)
{
label7.Text = "CPU #{0}"+ i;
label8.Text = "Tj.Max: " + CTInfo.GetTjMax[i] + "°" + TempType;
for (uint g = 0; g < CTInfo.GetCoreCount; g++)
{
index = g + (i * CTInfo.GetCoreCount);
if (CTInfo.IsDistanceToTjMax)
label9.Text= "Core #{0}: {1}°{2} to TjMax, {3}% Load"+ index+ CTInfo.GetTemp[index]+ TempType+ CTInfo.GetCoreLoad[index];
else
label10.Text = "Core #{0}: {1}°{2}, {3}% Load"+ index+ CTInfo.GetTemp[index]+ TempType+ CTInfo.GetCoreLoad[index];
}
}
}
else
{
Console.WriteLine();
label1.Text = "Internal error name: " + CTInfo.GetLastError;
Console.WriteLine("Internal error value: " + (int)CTInfo.GetLastError);
Console.WriteLine("Internal error message: " + CTInfo.GetErrorMessage(CTInfo.GetLastError));
}
}
private void CTInfo_ReportError(ErrorCodes ErrCode, string ErrMsg)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ErrMsg);
Console.ResetColor();
}
}
}
I have windows 7 64bit and gtx 580 video card. I wanted to get/display the video card gpu temperature.
Thanks for helping.