如何获取Cpu状态和风扇转速?(50分)

  • 主题发起人 Alpinist
  • 开始时间
A

Alpinist

Unregistered / Unconfirmed
GUEST, unregistred user!
<br>是否有直接的Api函数?<br>Cpu状态,比如:频率,温度等
 
得到Cpu主频<br>function GetCPUSpeed: Double;<br>const<br>&nbsp; DelayTime = 500;<br>var<br>&nbsp; TimerHi, TimerLo: DWORD;<br>&nbsp; PriorityClass, Priority: Integer;<br>begin<br>try<br>&nbsp; PriorityClass := GetPriorityClass(GetCurrentProcess);<br>&nbsp; Priority := GetThreadPriority(GetCurrentThread);<br>&nbsp; SetPriorityClass(GetCurrentProcess, REALTIME_PRIORITY_CLASS);<br>&nbsp; SetThreadPriority(GetCurrentThread,THREAD_PRIORITY_TIME_CRITICAL);<br>&nbsp; Sleep(10);<br>&nbsp; asm<br>&nbsp; &nbsp; dw 310Fh // rdtsc<br>&nbsp; &nbsp; mov TimerLo, eax<br>&nbsp; &nbsp; mov TimerHi, edx<br>&nbsp; end;<br>&nbsp; Sleep(DelayTime);<br>&nbsp; asm<br>&nbsp; &nbsp; dw 310Fh // rdtsc<br>&nbsp; &nbsp; sub eax, TimerLo<br>&nbsp; &nbsp; sbb edx, TimerHi<br>&nbsp; &nbsp; mov TimerLo, eax<br>&nbsp; &nbsp; mov TimerHi, edx<br>&nbsp; end;<br>&nbsp; SetThreadPriority(GetCurrentThread, Priority);<br>&nbsp; SetPriorityClass(GetCurrentProcess, PriorityClass);<br>&nbsp; Result := TimerLo / (1000.0 * DelayTime);<br>&nbsp; except<br>&nbsp; Result := 0;<br>&nbsp; end;<br>end; <br>CPU温度要在BIOS中才能读出来,而且这东西每块主板都不一样,肯定无法实现通用程序,<br>至于如何读,需要主板厂家给你提供接口吧?否则你怎么知道Bios中哪个值是温度啊?<br>风扇转数就是神仙也得不出来的,哈哈<br>
 
顶部