GetProcessInformation ProcessPowerThrottling does not seem to work

Mike Sullivan 21 Reputation points
2022-04-01T21:08:02.357+00:00

Hi. trying to examine the ProcessPowerThrottling structure because I want to make sure I am changing it. VS2019, SDK 10.0.22000.0
The Get fails, the Set succeeds (or so it says)

PROCESS_POWER_THROTTLING_STATE PowerThrottling;

// ProcessPowerThrottling - get PROCESS_POWER_THROTTLING_EXECUTION_SPEED
RtlZeroMemory(&PowerThrottling, sizeof(PROCESS_POWER_THROTTLING_STATE));
PowerThrottling.Version = PROCESS_POWER_THROTTLING_CURRENT_VERSION;
passFail = GetProcessInformation(
    GetCurrentProcess(),
    ProcessPowerThrottling,
    &PowerThrottling,
    sizeof(PROCESS_POWER_THROTTLING_STATE));

std::cout << "Get PowerThrottling, passFail:" << passFail << std::endl;
if (!passFail) {
    DWORD dw = GetLastError();
    std::cout << "PowerThrottling, failed:" << dw << std::endl;
}

output is

Get PowerThrottling, passFail:0
PowerThrottling, failed:87
Version:1
ControlMask:0
StateMask:0

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,472 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,591 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
8,614 questions
{count} votes

2 additional answers

Sort by: Most helpful
  1. Castorix31 82,321 Reputation points
    2022-04-02T07:54:48.92+00:00

    ProcessPowerThrottling seems to be valid only for SetProcessInformation;
    For GetProcessInformation, it returns first :

    RtlNtStatusToDosError(STATUS_INVALID_INFO_CLASS)

    (then ERROR_INVALID_PARAMETER)


  2. Jeanine Zhang-MSFT 9,346 Reputation points Microsoft Vendor
    2022-04-13T09:07:54.15+00:00

    Hi,

    Welcome to Microsoft Q&A!

    This is document content issue in the statement of GetProcessInformation() API. Actually ProcessPowerThrottling is not a supported parameter in GetProcessInformation() API, but this is only used in SetProcessInformation() API. This is also claimed in the documentation of PROCESS_POWER_THROTTLING_STATE structure.

    According to the code of GetProcessInformation(), it will check ProcessInformationClass parameter for ProcessMemoryPriority / ProcessAppMemoryInfo / ProcessInPrivateInfo / ProcessProtectionLevelInfo / ProcessLeapSecondInfo / ProcessMachineTypeInfo, and other values will be treated as STATUS_INVALID_INFO_CLASS which eventually returns ERROR_INVALID_PARAMETER (0x57) in GetLastError().

    And I'm trying to report document content issue.

    Best Regards,

    Jeanine


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.