Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8724137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:46:03+00:00 2026-06-13T07:46:03+00:00

Ive written a code trying to activate the windows’ high perfomance power plan through

  • 0

Ive written a code trying to activate the windows’ high perfomance power plan through the winAPI in c++. It seems to work well for all the power plans (in my terminal they are called Balanced, Power saver and Dell) excepting for the one im interested in, the high performance plan! I would like the code to go over through all the power plans and when finding the high performance one just set it on and then quit. Ill put my code underneath in case anybody can help me. thanks in advance!

#include <windows.h>
#include <powrprof.h>
#include <iostream>
#include "stdio.h"
#include <ntstatus.h>
#include <string>
#pragma comment(lib, "powrprof.lib")

using namespace std;


int main(int argc, char **argv) {


//////////////////  SET ACTIVE HIGH PERFORMANCE PLAN  ///////////////////


//Variables
UCHAR displayBuffer[64] = " ";
DWORD displayBufferSize = sizeof(displayBuffer);
GUID buffer;
DWORD bufferSize = sizeof(buffer);

//Go throught the machine's power plans and activate the high performance one
for(int index = 0; ; index++)
{

    if (ERROR_SUCCESS == PowerEnumerate(NULL,NULL,&GUID_VIDEO_SUBGROUP,ACCESS_SCHEME,index,(UCHAR*)&buffer,&bufferSize) )
    {
        if (ERROR_SUCCESS == PowerReadFriendlyName(NULL,&buffer,&NO_SUBGROUP_GUID,NULL,displayBuffer,&displayBufferSize) )
        {
            wprintf(L"%s\n", (wchar_t*)displayBuffer);


            if( 0 == wcscmp ( (wchar_t*)displayBuffer, L"High Performance" ) )
            {
                cout << "High Performance Plan Found!\n";
                if (ERROR_SUCCESS == PowerSetActiveScheme(NULL,&buffer) )
                {
                cout << "* Setting Active High Performance Power Plan *";
                //std::cin.get(); //pause
                break;
                }

            }
        }

    }
    else break;
}


return 0;

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:46:04+00:00Added an answer on June 13, 2026 at 7:46 am

    This can be done a bit easier:

    PowerSetActiveScheme(0, &GUID_MIN_POWER_SAVINGS);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to rewrite code I've written in matlab in C++ instead. I have
I've never written Ajax before and I am currently trying to code up an
I've been trying to validate my code to calculate Mahalanobis distance written in Python
I am trying to learn generic types and I've written this code: public class
I'm trying to implement single sign-on for a web portal. I've written some code
I've written a code for searching a specific file , where the user enters
I've written a code for searching a specific file , where the user enters
I've written this code to create a list of email addresses from branch numbers.
I've written this code to delete duplicate rows in a column of an Excel
I've written this code to try and send a url as a post value

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.