资源简介
支持Intel 核心温度读取,AMD的不行
代码片段和文件信息
#include “stdafx.h“
#include “ReadCpuInfo.h“
#include
ReadCpuInfo::ReadCpuInfo()
{
ReadCpuInfoInit();
strcpy_s(fileName “CpuInfoRecord.txt“);
}
ReadCpuInfo::~ReadCpuInfo()
{
ReadCpuInfoExit();
}
void ReadCpuInfo::ReadCpuTemp()
{
for (size_t i = 0; i < coreNumber; i++)
{
int mask = 0x01 << i;
SetProcessAffinityMask(GetCurrentProcess() mask);
DWORD eax ebx ecx edx;
Rdmsr(0x19c &eax &edx);
cpuTemp[i] = 100 - ((eax & 0x7f0000) >> 16);
}
}
void ReadCpuInfo::ReadCpuInfoInit()
{
if (true == CheckAndPrint(“Init DLL function“ InitializeOls()))
{
if (true == CheckAndPrint(“IsCpuid function“ IsCpuid()))
{
if (true == CheckAndPrint(“Ismsr function“ IsMsr()))
{
DWORD eax ebx ecx edx;
Rdmsr(0x1A2 &eax &edx);
Tjmax = (eax & 0xff0000) >> 16;
//printf(“%d\n“ Tjmax); //show max temperature
SYSTEM_INFO sysInfo;
GetSystemInfo(&sysInfo);
coreNumber = sysInfo.dwNumberOfProcessors;
SetProcessAffinityMask(GetCurrentProcess() 1); //init read cpu0 info;
}
}
}
}
void ReadCpuInfo::ReadCpuInfoExit()
{
DeinitializeOls();
}
int ReadCpuInfo::CheckAndPrint(char message[] BOOL flag)
{
if (flag)
{
printf(“%s is checked Enable!\n“ message);
return 1;
}
else
{
printf(“%s is checked unEnabled!\n“ message);
return 0;
}
}
void ReadCpuInfo::CpuTempDisplay()
{
for (size_t i = 0; i < coreNumber; i++)
{
char buf[1024] = ““;
#if (CONSOLE_PRINT)
printf(“Core #%d: %dC\n“ i cpuTemp[i]);
#else
#endif
sprintf_s(buf “Core #%d: %dC\n“ i cpuTemp[i]);
RecordCpuInfo(buf);
}
}
void ReadCpuInfo::SysTimeDisplay()
{
clearRecordFile();
SYSTEMTIME start; //windows.h中
GetLocalTime(&start);//time.h的tm结构体一样的效果
//printf(“%d\n“ start.wHour);
#if (CONSOLE_PRINT)
printf(“date: %02d/%02d/%02d\n“
start.wYear start.wMonth start.wDay);
printf(“time: %02d:%02d:%02d\n“
start.wHour start.wMinute start.wSecond);
#else
#endif
char buf[1024] = ““;
sprintf_s(buf “date: %02d/%02d/%02d\n“ start.wYear start.wMonth start.wDay);
RecordCpuInfo(buf);
memset(buf 0 sizeof(buf));
sprintf_s(buf “time: %02d:%02d:%02d\n“start.wHour start.wMinute start.wSecond);
RecordCpuInfo(buf);
}
void ReadCpuInfo::RecordCpuInfo(char *buf)
{
FILE *fp;
fopen_s(&fpfileName “a+“);
if (fp == NULL)
{
printf(“file open error!\n“);
return;
}
else
{
fwrite(buf strlen(buf) 1 fp);
}
fclose(fp);
}
void ReadCpuInfo:: clearRecordFile()
{
FILE *fp;
fopen_s(&fpfileName “w+“);
if (fp == NULL)
{
printf(“file open error!\n“);
return ;
}
fclose(fp);
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-04-20 10:26 readPcInfo\
目录 0 2016-03-18 09:54 readPcInfo\Debug\
文件 90 2016-04-20 09:43 readPcInfo\Debug\CpuInfoRecord.txt
文件 65536 2016-03-08 15:36 readPcInfo\Debug\readPcInfo.exe
文件 389912 2016-03-08 15:36 readPcInfo\Debug\readPcInfo.ilk
文件 1256448 2016-03-08 15:36 readPcInfo\Debug\readPcInfo.pdb
文件 65536 2009-05-24 11:34 readPcInfo\Debug\WinRing0.dll
文件 14416 2008-07-26 22:30 readPcInfo\Debug\WinRing0.sys
文件 57856 2009-05-27 21:59 readPcInfo\Debug\WinRing0x64.dll
文件 14544 2008-07-26 22:30 readPcInfo\Debug\WinRing0x64.sys
目录 0 2016-03-22 16:52 readPcInfo\ipch\
目录 0 2016-04-20 09:44 readPcInfo\ipch\readpcinfo-28a6d5b0\
文件 3080192 2016-04-20 09:44 readPcInfo\ipch\readpcinfo-28a6d5b0\readpcinfo-b71dfa21.ipch
目录 0 2016-03-18 09:54 readPcInfo\ipch\readpcinfo-e29dfd5d\
文件 3080192 2016-03-08 15:36 readPcInfo\ipch\readpcinfo-e29dfd5d\readpcinfo-7740a867.ipch
目录 0 2016-04-20 10:23 readPcInfo\readPcInfo\
文件 32571392 2016-04-20 10:26 readPcInfo\readPcInfo.sdf
文件 976 2016-03-08 09:10 readPcInfo\readPcInfo.sln
文件 35840 2016-04-20 10:26 readPcInfo\readPcInfo.v12.suo
文件 90 2016-04-20 10:23 readPcInfo\readPcInfo\CpuInfoRecord.txt
目录 0 2016-03-18 09:54 readPcInfo\readPcInfo\Debug\
文件 7122 2016-03-08 14:12 readPcInfo\readPcInfo\Debug\CpuInfoWriteFile.obj
文件 48271 2016-03-08 14:56 readPcInfo\readPcInfo\Debug\ReadCpuInfo.obj
文件 1142 2016-03-08 15:36 readPcInfo\readPcInfo\Debug\readPcInfo.log
文件 164624 2016-03-08 14:56 readPcInfo\readPcInfo\Debug\readPcInfo.obj
文件 2424832 2016-03-08 14:11 readPcInfo\readPcInfo\Debug\readPcInfo.pch
目录 0 2016-03-18 09:54 readPcInfo\readPcInfo\Debug\readPcInfo.tlog\
文件 3174 2016-03-08 14:56 readPcInfo\readPcInfo\Debug\readPcInfo.tlog\cl.command.1.tlog
文件 43688 2016-03-08 15:36 readPcInfo\readPcInfo\Debug\readPcInfo.tlog\CL.read.1.tlog
文件 4372 2016-03-08 14:56 readPcInfo\readPcInfo\Debug\readPcInfo.tlog\CL.write.1.tlog
文件 1618 2016-03-08 15:36 readPcInfo\readPcInfo\Debug\readPcInfo.tlog\li
............此处省略42个文件信息
- 上一篇:IBM DS系列存储配置说明电子书
- 下一篇:徐德鸿开关电源小信号建模
相关资源
- intel微处理器结构编程与接口第六版,
- sublime_text_SublimeCodeIntel.rar
- Intel SGX SDK for Windows v2.4.100.51291.exe
- 智能汽车手册handbook Intelligent Vehicle
- Prolog Programming for Artificial Intelligence
- ippicv_2019_lnx_intel64_general_20180723.tgz
- Artificial Intelligence A Modern Approach 3rd
- Intellij IDEA 最完美编程字体 Yahei-Mona
- springMvc+Mybatis+maven+intellj idea环境搭建
- Intel手册完整版三册全
- Artificial Intelligence for Humans Volume 1-3
- intel手册软件开发者手册全
- Hands-On Intelligent Agents with OpenAI Gym
- ippicv_2019_win_intel64_20180723_general.7z
- Intel微处理器结构、编程与接口 第六
- ArtificialIntelligence-AModernApproach3rdEditi
- ippicv_2017u3_lnx_intel64_20170822.tgz包
- Paradigms-of-Artificial-Intelligence-Programmi
- TensorFlow For Machine Intelligence(非扫描版
- 黑苹果EFI文件备份Intel I5 3450 华硕H
- springmvc 人事管理系统 intellij idea 工程
- Intel SGX PSW for Windows v2.0.101.44269
- IntelliJ IDEA 2018.1 汉化包
- 2018年英特尔 64 和 IA-32 架构软件开发
- Intellij IDEA 2018汉化包 亲测设置可用
- idea中ssm框架整合
- Intel S2400SC 做RAID系统安装图文教程
- Intellij IDEA搭建SSM+Bootstrp+分页
- ippicv_2020_win_intel64_20191018_general.zip
- Machine Learning and Intelligent Communication
评论
共有 条评论