hasyed
2010-08-05 20:26:03 UTC
From my windows user-mode environment, I would like to read the temperature
of the thermal zones. I don't want to use WMI since those values are not
updated on most systems. I would like to use IOCTL_ACPI_EVAL_METHOD.
Using device manager, I see that the thermal zones don't really have a
driver associated with them. Nevertheless, I tried the following code below.
I am able to get a handle to the thermal zone using CreateFile
hDevice = CreateFile(szDevicePath, (DWORD)(GENERIC_READ | GENERIC_WRITE), 0,
NULL,OPEN_EXISTING,0,NULL);
if (hDevice == INVALID_HANDLE_VALUE)
{
return 0;
}
InBuf.Signature = ACPI_EVAL_INPUT_BUFFER_SIGNATURE;
InBuf.MethodName[0] = '_';
InBuf.MethodName[1] = 'T';
InBuf.MethodName[2] = 'M';
InBuf.MethodName[3] = 'P';
// Verify Driver version from driver
IoctlResult = DeviceIoControl(hDevice,
IOCTL_ACPI_EVAL_METHOD,
&InBuf, (DWORD) sizeof(InBuf), // Input
&OutBuff, (DWORD) sizeof(OutBuff), //
Output
&ReturnedLength,
NULL);
The IoctlResult in Vista returns a 1 and the OutBuff contains junk data. In
XP, IoctlResult is a 0 (fail).
To get the handle to the thermal zone, I used functions SetupDiGetClassDevs,
SetupDiEnumDeviceInterfaces, SetupDiGetDeviceInterfaceDetail with the
thermalzone guid.
Am I on the right path? What am I missing?
Thanks for any guidance.
of the thermal zones. I don't want to use WMI since those values are not
updated on most systems. I would like to use IOCTL_ACPI_EVAL_METHOD.
Using device manager, I see that the thermal zones don't really have a
driver associated with them. Nevertheless, I tried the following code below.
I am able to get a handle to the thermal zone using CreateFile
hDevice = CreateFile(szDevicePath, (DWORD)(GENERIC_READ | GENERIC_WRITE), 0,
NULL,OPEN_EXISTING,0,NULL);
if (hDevice == INVALID_HANDLE_VALUE)
{
return 0;
}
InBuf.Signature = ACPI_EVAL_INPUT_BUFFER_SIGNATURE;
InBuf.MethodName[0] = '_';
InBuf.MethodName[1] = 'T';
InBuf.MethodName[2] = 'M';
InBuf.MethodName[3] = 'P';
// Verify Driver version from driver
IoctlResult = DeviceIoControl(hDevice,
IOCTL_ACPI_EVAL_METHOD,
&InBuf, (DWORD) sizeof(InBuf), // Input
&OutBuff, (DWORD) sizeof(OutBuff), //
Output
&ReturnedLength,
NULL);
The IoctlResult in Vista returns a 1 and the OutBuff contains junk data. In
XP, IoctlResult is a 0 (fail).
To get the handle to the thermal zone, I used functions SetupDiGetClassDevs,
SetupDiEnumDeviceInterfaces, SetupDiGetDeviceInterfaceDetail with the
thermalzone guid.
Am I on the right path? What am I missing?
Thanks for any guidance.