You can try this, derivated from Learn Microsoft - EcoQS and updated for Delphi (sorry for errors):
//I use _my to discriminate from bundle definitions
uses WinApi.Windows; //Add this to uses unit
type
///<summary>Documentation: https://docs.microsoft.com/windows/win32/api/processthreadsapi/ne-processthreadsapi-process_information_class</summary>
PROCESS_INFORMATION_CLASS_my = (
ProcessMemoryPriority,
ProcessMemoryExhaustionInfo,
ProcessAppMemoryInfo,
ProcessInPrivateInfo,
ProcessPowerThrottling,
ProcessReservedValue1,
ProcessTelemetryCoverageInfo,
ProcessProtectionLevelInfo,
ProcessLeapSecondInfo,
ProcessMachineTypeInfo,
ProcessInformationClassMax
);
type
_PROCESS_POWER_THROTTLING_STATE = record
Version: ULONG;
ControlMask: ULONG;
StateMask: ULONG;
end;
PROCESS_POWER_THROTTLING_STATE = _PROCESS_POWER_THROTTLING_STATE;
PPROCESS_POWER_THROTTLING_STATE = ^PROCESS_POWER_THROTTLING_STATE;
const
PROCESS_POWER_THROTTLING_CURRENT_VERSION = 1;
PROCESS_POWER_THROTTLING_EXECUTION_SPEED = $1;
//Redefine API
function SetProcessInformation_my(hProcess: THandle; ProcessInformationClass: PROCESS_INFORMATION_CLASS_my;
ProcessInformation: Pointer; ProcessInformationSize: DWORD): ByteBool; stdcall;
function SetProcessInformation_my; external kernel32 name 'SetProcessInformation' delayed;
implementation
{$R *.fmx}
function SetEfficiencyMode(PID: DWORD): Boolean;
var
hProcess: THandle;
PowerState: PROCESS_POWER_THROTTLING_STATE;
begin
Result := false;
hProcess := OpenProcess(PROCESS_SET_INFORMATION, False, PID);
if hProcess <> 0 then
begin
ZeroMemory(@PowerState, SizeOf(PowerState));
PowerState.Version := PROCESS_POWER_THROTTLING_CURRENT_VERSION;
PowerState.ControlMask := PROCESS_POWER_THROTTLING_EXECUTION_SPEED;
PowerState.StateMask := PROCESS_POWER_THROTTLING_EXECUTION_SPEED;
Result := SetProcessInformation_my(hProcess, Process_Information_Class_my(ProcessPowerThrottling), @PowerState, SizeOf(PowerState));
CloseHandle(hProcess);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var Success: boolean;
begin
Success := SetEfficiencyMode(GetCurrentProcessId);
if Success then
ShowMessage('Efficiency mode activated successfully!')
else
ShowMessage('Error activating efficiency mode.');
end;