Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access laptop battery temperature in Windows?

I want to get the battery temperature in Windows, and I have tried DeviceIoControl function (http://msdn.microsoft.com/en-us/library/aa372698(v=vs.85).aspx) on the BatteryTemperature.

I have tried other parameter like BatterySerialNumber, and it returns the serial number, but while I want to get the temperature, the function returns FALSE. And GetLastError returns S_FALSE.

My enviroment is Win7 Enterprise SP1, I developed on VS2008+SP1, total C++ code, my laptop is HP Elitebook 2570p. Can anyone give some suggestions on this topic. I have searched Google and donot find any help topic, or should I write some driver code to get the temperature? Or this laptop battery doesnot support this function?

Thanks very much.

PS. If there are any other tech which can get the temperature is welcome, not only in C++.

like image 239
thinkinnight Avatar asked Nov 11 '22 20:11

thinkinnight


1 Answers

S_FALSE returned by GetLastError is also just 1, which is also ERROR_INVALID_FUNCTION. Extract from MSDN:

If the particular type of data requested is not available for the current battery, then ERROR_INVALID_FUNCTION is returned.

This means your battery has no temperature sensor or manufacturer who written the battery driver decided not to provide this information to Windows.

like image 191
Oleg Korzhukov Avatar answered Nov 15 '22 07:11

Oleg Korzhukov