c - How to access CPU's heat sensors? -


I am working on software where I need access to the temperature sensor in the CPU and gets control over it.

I do not know much hardware interface; I just know how to interface with the mouse. I have done a lot about it but have failed to find any relevant information or piece of code.

I need to add it to my software Please guide me to control sensors that use C or C ++ or ASM.

Without a specific kernel driver, it is difficult to ask temperature, other than WMI. This is a piece of C code based on the MSAcpi_ThermalZoneTemperature class of WMI:

  HRESULT GetCpuTemperature (LPLONG p temperature) {If (P temperature == faucet) back E_INVALIDARG; * P temperature = -1; HRESULT ci = CoInitialize (NULL); // needs comdef.h HRESULT hr = CoInitializeSecurity (zero, -1, zero, NULL, RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL); If (SUCCEEDED (HR)) {IWbemLocator * pLocator; // Wbemidl.h and amp; Wbemuuid.lib hr = CoCreateInstance (CLSID_WbemAdministrativeLocator, NULL, CLSCTX_INPROC_SERVER, IID_IWbemLocator, (LPVOID *) and PLoketer); If (SUCCEEDED (HR)) {IWbemServices * pServices; BSTR NS = SysAllocString (L "Root \\ WMI"); Hr = pollator- & gt; Connector Server (Ns, NULL, NULL, NULL, 0, NULL, NULL, and P Services); PLocator- & gt; Release (); SysFreeString (NS); If (SUCCEEDED (HR)) {BSTR Query = SysAllocString (L "SELECT * FROM MSAcpi_ThermalZoneTemperature"); BSTR wql = SysAllocString (L "WQL"); IEnumWbemClassObject * pEnum; Hr = pServices-> ExecQuery (wql, query, WBEM_FLAG_RETURN_IMMEDIATELY | WBEM_FLAG_FORWARD_ONLY, NULL, and pEnum); SysFreeString (WQL); SysFreeString (query); PServices-> Release (); If (SUCCEEDED (HR)) {IWbemClassObject * pObject; Cloves returned; Hr = pEnum-> gt; Next (WBEM_INFINITE, 1, and pObject, & amp; amp; back); PEnum-> Release (); If (SUCCEEDED (HR)) {BSTR temp = SysAllocString (L "current temperature"); Various V; VariantInit (& amp; V); Hr = pObject-> Get (temp, 0, & amp; v, NULL, NULL); PObject-> Release (); SysFreeString (Temporary); If (SUCCEEDED (HR)) {* P temperature = V_I4 (& amp; v); } Variant Claire (& amp; v); }}} If (CI == S_OK) {CoenIneIsize (); }}} Returns HR; }   

and some trial code:

  HRESULT GetCpu temperature (LPLONG p temperature); Int _tmain (int argc, _TCHAR * argv []) {long temp; HRESULT hour = GetCpu temperature (& amp; temp); Printf ("hr = 0x% 08x temp =% i \ n", hr, temporary); }    

Comments