1 /*
2 * PROJECT: ReactOS Task Manager
3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4 * PURPOSE: Process Priority.
5 * COPYRIGHT: Copyright 1999-2001 Brian Palmer <brianp@reactos.org>
6 * Copyright 2005 Klemens Friedl <frik85@reactos.at>
7 */
8
9 #include "precomp.h"
10
DoSetPriority(DWORD priority)11 void DoSetPriority(DWORD priority)
12 {
13 DWORD dwProcessId;
14 HANDLE hProcess;
15 WCHAR szText[260];
16 WCHAR szTitle[256];
17
18 dwProcessId = GetSelectedProcessId();
19
20 if (dwProcessId == 0)
21 return;
22
23 LoadStringW(hInst, IDS_MSG_TASKMGRWARNING, szTitle, 256);
24 LoadStringW(hInst, IDS_MSG_WARNINGCHANGEPRIORITY, szText, 260);
25 if (!ConfirmMessageBox(hMainWnd, szText, szTitle, MB_YESNO|MB_ICONWARNING))
26 return;
27
28 hProcess = OpenProcess(PROCESS_SET_INFORMATION, FALSE, dwProcessId);
29
30 if (!hProcess)
31 {
32 GetLastErrorText(szText, 260);
33 LoadStringW(hInst, IDS_MSG_UNABLECHANGEPRIORITY, szTitle, 256);
34 MessageBoxW(hMainWnd, szText, szTitle, MB_OK|MB_ICONSTOP);
35 return;
36 }
37
38 if (!SetPriorityClass(hProcess, priority))
39 {
40 GetLastErrorText(szText, 260);
41 LoadStringW(hInst, IDS_MSG_UNABLECHANGEPRIORITY, szTitle, 256);
42 MessageBoxW(hMainWnd, szText, szTitle, MB_OK|MB_ICONSTOP);
43 }
44
45 CloseHandle(hProcess);
46 }
47