GetThreadInformation() fails

Viewed 169

Pretty simple thing, I want to use GetThreadInformation() from the windows API. Usage seems pretty simple from its documentation, but it fails. Code:

THREAD_POWER_THROTTLING_STATE state{};
const bool return_value = GetThreadInformation(
   GetCurrentThread(),
   ThreadPowerThrottling,
   &state,
   sizeof(THREAD_POWER_THROTTLING_STATE)
);

Return value is always false, which indicates an error. GetLastError() indicates a wrong parameter. The documentation does talk about that the thread needs to have the proper rights. But GetCurrentThread() documentation clearly states that it returns a handle with THREAD_ALL_ACCESS rights. So what's wrong? This is on Win10.

1 Answers

the documetation of GetThreadInformation is wrong.

in part ThreadInformationClass: really supported values is: ThreadMemoryPriority, ThreadAbsoluteCpuPriority and ThreadDynamicCodePolicy

the ThreadPowerThrottling is accepted only by SetThreadInformation.

so if pass ThreadPowerThrottling to GetThreadInformation we always got ERROR_INVALID_PARAMETER

Related