6 * Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
36 void ProcessPage_OnSetPriorityRealTime(void)
42 TCHAR strErrorText
[260];
44 for (Index
=0; Index
<(ULONG
)ListView_GetItemCount(hProcessPageListCtrl
); Index
++)
46 memset(&lvitem
, 0, sizeof(LVITEM
));
48 lvitem
.mask
= LVIF_STATE
;
49 lvitem
.stateMask
= LVIS_SELECTED
;
52 ListView_GetItem(hProcessPageListCtrl
, &lvitem
);
54 if (lvitem
.state
& LVIS_SELECTED
)
58 dwProcessId
= PerfDataGetProcessId(Index
);
60 if ((ListView_GetSelectedCount(hProcessPageListCtrl
) != 1) || (dwProcessId
== 0))
63 if (MessageBox(hMainWnd
, _T("WARNING: Changing the priority class of this process may\ncause undesired results including system instability. Are you\nsure you want to change the priority class?"), _T("Task Manager Warning"), MB_YESNO
|MB_ICONWARNING
) != IDYES
)
66 hProcess
= OpenProcess(PROCESS_SET_INFORMATION
, FALSE
, dwProcessId
);
70 GetLastErrorText(strErrorText
, 260);
71 MessageBox(hMainWnd
, strErrorText
, _T("Unable to Change Priority"), MB_OK
|MB_ICONSTOP
);
75 if (!SetPriorityClass(hProcess
, REALTIME_PRIORITY_CLASS
))
77 GetLastErrorText(strErrorText
, 260);
78 MessageBox(hMainWnd
, strErrorText
, _T("Unable to Change Priority"), MB_OK
|MB_ICONSTOP
);
81 CloseHandle(hProcess
);
84 void ProcessPage_OnSetPriorityHigh(void)
90 TCHAR strErrorText
[260];
92 for (Index
=0; Index
<(ULONG
)ListView_GetItemCount(hProcessPageListCtrl
); Index
++)
94 memset(&lvitem
, 0, sizeof(LVITEM
));
96 lvitem
.mask
= LVIF_STATE
;
97 lvitem
.stateMask
= LVIS_SELECTED
;
100 ListView_GetItem(hProcessPageListCtrl
, &lvitem
);
102 if (lvitem
.state
& LVIS_SELECTED
)
106 dwProcessId
= PerfDataGetProcessId(Index
);
108 if ((ListView_GetSelectedCount(hProcessPageListCtrl
) != 1) || (dwProcessId
== 0))
111 if (MessageBox(hMainWnd
, _T("WARNING: Changing the priority class of this process may\ncause undesired results including system instability. Are you\nsure you want to change the priority class?"), _T("Task Manager Warning"), MB_YESNO
|MB_ICONWARNING
) != IDYES
)
114 hProcess
= OpenProcess(PROCESS_SET_INFORMATION
, FALSE
, dwProcessId
);
118 GetLastErrorText(strErrorText
, 260);
119 MessageBox(hMainWnd
, strErrorText
, _T("Unable to Change Priority"), MB_OK
|MB_ICONSTOP
);
123 if (!SetPriorityClass(hProcess
, HIGH_PRIORITY_CLASS
))
125 GetLastErrorText(strErrorText
, 260);
126 MessageBox(hMainWnd
, strErrorText
, _T("Unable to Change Priority"), MB_OK
|MB_ICONSTOP
);
129 CloseHandle(hProcess
);
132 void ProcessPage_OnSetPriorityAboveNormal(void)
138 TCHAR strErrorText
[260];
140 for (Index
=0; Index
<(ULONG
)ListView_GetItemCount(hProcessPageListCtrl
); Index
++)
142 memset(&lvitem
, 0, sizeof(LVITEM
));
144 lvitem
.mask
= LVIF_STATE
;
145 lvitem
.stateMask
= LVIS_SELECTED
;
146 lvitem
.iItem
= Index
;
148 ListView_GetItem(hProcessPageListCtrl
, &lvitem
);
150 if (lvitem
.state
& LVIS_SELECTED
)
154 dwProcessId
= PerfDataGetProcessId(Index
);
156 if ((ListView_GetSelectedCount(hProcessPageListCtrl
) != 1) || (dwProcessId
== 0))
159 if (MessageBox(hMainWnd
, _T("WARNING: Changing the priority class of this process may\ncause undesired results including system instability. Are you\nsure you want to change the priority class?"), _T("Task Manager Warning"), MB_YESNO
|MB_ICONWARNING
) != IDYES
)
162 hProcess
= OpenProcess(PROCESS_SET_INFORMATION
, FALSE
, dwProcessId
);
166 GetLastErrorText(strErrorText
, 260);
167 MessageBox(hMainWnd
, strErrorText
, _T("Unable to Change Priority"), MB_OK
|MB_ICONSTOP
);
171 if (!SetPriorityClass(hProcess
, ABOVE_NORMAL_PRIORITY_CLASS
))
173 GetLastErrorText(strErrorText
, 260);
174 MessageBox(hMainWnd
, strErrorText
, _T("Unable to Change Priority"), MB_OK
|MB_ICONSTOP
);
177 CloseHandle(hProcess
);
180 void ProcessPage_OnSetPriorityNormal(void)
186 TCHAR strErrorText
[260];
188 for (Index
=0; Index
<(ULONG
)ListView_GetItemCount(hProcessPageListCtrl
); Index
++)
190 memset(&lvitem
, 0, sizeof(LVITEM
));
192 lvitem
.mask
= LVIF_STATE
;
193 lvitem
.stateMask
= LVIS_SELECTED
;
194 lvitem
.iItem
= Index
;
196 ListView_GetItem(hProcessPageListCtrl
, &lvitem
);
198 if (lvitem
.state
& LVIS_SELECTED
)
202 dwProcessId
= PerfDataGetProcessId(Index
);
204 if ((ListView_GetSelectedCount(hProcessPageListCtrl
) != 1) || (dwProcessId
== 0))
207 if (MessageBox(hMainWnd
, _T("WARNING: Changing the priority class of this process may\ncause undesired results including system instability. Are you\nsure you want to change the priority class?"), _T("Task Manager Warning"), MB_YESNO
|MB_ICONWARNING
) != IDYES
)
210 hProcess
= OpenProcess(PROCESS_SET_INFORMATION
, FALSE
, dwProcessId
);
214 GetLastErrorText(strErrorText
, 260);
215 MessageBox(hMainWnd
, strErrorText
, _T("Unable to Change Priority"), MB_OK
|MB_ICONSTOP
);
219 if (!SetPriorityClass(hProcess
, NORMAL_PRIORITY_CLASS
))
221 GetLastErrorText(strErrorText
, 260);
222 MessageBox(hMainWnd
, strErrorText
, _T("Unable to Change Priority"), MB_OK
|MB_ICONSTOP
);
225 CloseHandle(hProcess
);
228 void ProcessPage_OnSetPriorityBelowNormal(void)
234 TCHAR strErrorText
[260];
236 for (Index
=0; Index
<(ULONG
)ListView_GetItemCount(hProcessPageListCtrl
); Index
++)
238 memset(&lvitem
, 0, sizeof(LVITEM
));
240 lvitem
.mask
= LVIF_STATE
;
241 lvitem
.stateMask
= LVIS_SELECTED
;
242 lvitem
.iItem
= Index
;
244 ListView_GetItem(hProcessPageListCtrl
, &lvitem
);
246 if (lvitem
.state
& LVIS_SELECTED
)
250 dwProcessId
= PerfDataGetProcessId(Index
);
252 if ((ListView_GetSelectedCount(hProcessPageListCtrl
) != 1) || (dwProcessId
== 0))
255 if (MessageBox(hMainWnd
, _T("WARNING: Changing the priority class of this process may\ncause undesired results including system instability. Are you\nsure you want to change the priority class?"), _T("Task Manager Warning"), MB_YESNO
|MB_ICONWARNING
) != IDYES
)
258 hProcess
= OpenProcess(PROCESS_SET_INFORMATION
, FALSE
, dwProcessId
);
262 GetLastErrorText(strErrorText
, 260);
263 MessageBox(hMainWnd
, strErrorText
, _T("Unable to Change Priority"), MB_OK
|MB_ICONSTOP
);
267 if (!SetPriorityClass(hProcess
, BELOW_NORMAL_PRIORITY_CLASS
))
269 GetLastErrorText(strErrorText
, 260);
270 MessageBox(hMainWnd
, strErrorText
, _T("Unable to Change Priority"), MB_OK
|MB_ICONSTOP
);
273 CloseHandle(hProcess
);
276 void ProcessPage_OnSetPriorityLow(void)
282 TCHAR strErrorText
[260];
284 for (Index
=0; Index
<(ULONG
)ListView_GetItemCount(hProcessPageListCtrl
); Index
++)
286 memset(&lvitem
, 0, sizeof(LVITEM
));
288 lvitem
.mask
= LVIF_STATE
;
289 lvitem
.stateMask
= LVIS_SELECTED
;
290 lvitem
.iItem
= Index
;
292 ListView_GetItem(hProcessPageListCtrl
, &lvitem
);
294 if (lvitem
.state
& LVIS_SELECTED
)
298 dwProcessId
= PerfDataGetProcessId(Index
);
300 if ((ListView_GetSelectedCount(hProcessPageListCtrl
) != 1) || (dwProcessId
== 0))
303 if (MessageBox(hMainWnd
, _T("WARNING: Changing the priority class of this process may\ncause undesired results including system instability. Are you\nsure you want to change the priority class?"), _T("Task Manager Warning"), MB_YESNO
|MB_ICONWARNING
) != IDYES
)
306 hProcess
= OpenProcess(PROCESS_SET_INFORMATION
, FALSE
, dwProcessId
);
310 GetLastErrorText(strErrorText
, 260);
311 MessageBox(hMainWnd
, strErrorText
, _T("Unable to Change Priority"), MB_OK
|MB_ICONSTOP
);
315 if (!SetPriorityClass(hProcess
, IDLE_PRIORITY_CLASS
))
317 GetLastErrorText(strErrorText
, 260);
318 MessageBox(hMainWnd
, strErrorText
, _T("Unable to Change Priority"), MB_OK
|MB_ICONSTOP
);
321 CloseHandle(hProcess
);