6 * Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
7 * 2005 Klemens Friedl <frik85@reactos.at>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 void ProcessPage_OnSetPriorityRealTime(void)
35 TCHAR strErrorText
[260];
37 for (Index
=0; Index
<(ULONG
)ListView_GetItemCount(hProcessPageListCtrl
); Index
++)
39 memset(&lvitem
, 0, sizeof(LVITEM
));
41 lvitem
.mask
= LVIF_STATE
;
42 lvitem
.stateMask
= LVIS_SELECTED
;
45 ListView_GetItem(hProcessPageListCtrl
, &lvitem
);
47 if (lvitem
.state
& LVIS_SELECTED
)
51 dwProcessId
= PerfDataGetProcessId(Index
);
53 if ((ListView_GetSelectedCount(hProcessPageListCtrl
) != 1) || (dwProcessId
== 0))
56 LoadString(hInst
, IDS_MSG_WARNINGCHANGEPRIORITY
, szTemp
, 256);
57 LoadString(hInst
, IDS_MSG_TASKMGRWARNING
, szTempA
, 256);
58 if (MessageBox(hMainWnd
, szTemp
, szTempA
, MB_YESNO
|MB_ICONWARNING
) != IDYES
)
61 hProcess
= OpenProcess(PROCESS_SET_INFORMATION
, FALSE
, dwProcessId
);
65 GetLastErrorText(strErrorText
, 260);
66 LoadString(hInst
, IDS_MSG_UNABLECHANGEPRIORITY
, szTemp
, 256);
67 MessageBox(hMainWnd
, strErrorText
, szTemp
, MB_OK
|MB_ICONSTOP
);
71 if (!SetPriorityClass(hProcess
, REALTIME_PRIORITY_CLASS
))
73 GetLastErrorText(strErrorText
, 260);
74 LoadString(hInst
, IDS_MSG_UNABLECHANGEPRIORITY
, szTemp
, 256);
75 MessageBox(hMainWnd
, strErrorText
, szTemp
, MB_OK
|MB_ICONSTOP
);
78 CloseHandle(hProcess
);
81 void ProcessPage_OnSetPriorityHigh(void)
87 TCHAR strErrorText
[260];
89 for (Index
=0; Index
<(ULONG
)ListView_GetItemCount(hProcessPageListCtrl
); Index
++)
91 memset(&lvitem
, 0, sizeof(LVITEM
));
93 lvitem
.mask
= LVIF_STATE
;
94 lvitem
.stateMask
= LVIS_SELECTED
;
97 ListView_GetItem(hProcessPageListCtrl
, &lvitem
);
99 if (lvitem
.state
& LVIS_SELECTED
)
103 dwProcessId
= PerfDataGetProcessId(Index
);
105 if ((ListView_GetSelectedCount(hProcessPageListCtrl
) != 1) || (dwProcessId
== 0))
108 LoadString(hInst
, IDS_MSG_WARNINGCHANGEPRIORITY
, szTemp
, 256);
109 LoadString(hInst
, IDS_MSG_TASKMGRWARNING
, szTempA
, 256);
110 if (MessageBox(hMainWnd
, szTemp
, szTempA
, MB_YESNO
|MB_ICONWARNING
) != IDYES
)
113 hProcess
= OpenProcess(PROCESS_SET_INFORMATION
, FALSE
, dwProcessId
);
117 GetLastErrorText(strErrorText
, 260);
118 LoadString(hInst
, IDS_MSG_UNABLECHANGEPRIORITY
, szTemp
, 256);
119 MessageBox(hMainWnd
, strErrorText
, szTemp
, MB_OK
|MB_ICONSTOP
);
123 if (!SetPriorityClass(hProcess
, HIGH_PRIORITY_CLASS
))
125 GetLastErrorText(strErrorText
, 260);
126 LoadString(hInst
, IDS_MSG_UNABLECHANGEPRIORITY
, szTemp
, 256);
127 MessageBox(hMainWnd
, strErrorText
, szTemp
, MB_OK
|MB_ICONSTOP
);
130 CloseHandle(hProcess
);
133 void ProcessPage_OnSetPriorityAboveNormal(void)
139 TCHAR strErrorText
[260];
141 for (Index
=0; Index
<(ULONG
)ListView_GetItemCount(hProcessPageListCtrl
); Index
++)
143 memset(&lvitem
, 0, sizeof(LVITEM
));
145 lvitem
.mask
= LVIF_STATE
;
146 lvitem
.stateMask
= LVIS_SELECTED
;
147 lvitem
.iItem
= Index
;
149 ListView_GetItem(hProcessPageListCtrl
, &lvitem
);
151 if (lvitem
.state
& LVIS_SELECTED
)
155 dwProcessId
= PerfDataGetProcessId(Index
);
157 if ((ListView_GetSelectedCount(hProcessPageListCtrl
) != 1) || (dwProcessId
== 0))
160 LoadString(hInst
, IDS_MSG_WARNINGCHANGEPRIORITY
, szTemp
, 256);
161 LoadString(hInst
, IDS_MSG_TASKMGRWARNING
, szTempA
, 256);
162 if (MessageBox(hMainWnd
, szTemp
, szTempA
, MB_YESNO
|MB_ICONWARNING
) != IDYES
)
165 hProcess
= OpenProcess(PROCESS_SET_INFORMATION
, FALSE
, dwProcessId
);
169 GetLastErrorText(strErrorText
, 260);
170 LoadString(hInst
, IDS_MSG_UNABLECHANGEPRIORITY
, szTemp
, 256);
171 MessageBox(hMainWnd
, strErrorText
, szTemp
, MB_OK
|MB_ICONSTOP
);
175 if (!SetPriorityClass(hProcess
, ABOVE_NORMAL_PRIORITY_CLASS
))
177 GetLastErrorText(strErrorText
, 260);
178 LoadString(hInst
, IDS_MSG_UNABLECHANGEPRIORITY
, szTemp
, 256);
179 MessageBox(hMainWnd
, strErrorText
, szTemp
, MB_OK
|MB_ICONSTOP
);
182 CloseHandle(hProcess
);
185 void ProcessPage_OnSetPriorityNormal(void)
191 TCHAR strErrorText
[260];
193 for (Index
=0; Index
<(ULONG
)ListView_GetItemCount(hProcessPageListCtrl
); Index
++)
195 memset(&lvitem
, 0, sizeof(LVITEM
));
197 lvitem
.mask
= LVIF_STATE
;
198 lvitem
.stateMask
= LVIS_SELECTED
;
199 lvitem
.iItem
= Index
;
201 ListView_GetItem(hProcessPageListCtrl
, &lvitem
);
203 if (lvitem
.state
& LVIS_SELECTED
)
207 dwProcessId
= PerfDataGetProcessId(Index
);
209 if ((ListView_GetSelectedCount(hProcessPageListCtrl
) != 1) || (dwProcessId
== 0))
212 LoadString(hInst
, IDS_MSG_WARNINGCHANGEPRIORITY
, szTemp
, 256);
213 LoadString(hInst
, IDS_MSG_TASKMGRWARNING
, szTempA
, 256);
214 if (MessageBox(hMainWnd
, szTemp
, szTempA
, MB_YESNO
|MB_ICONWARNING
) != IDYES
)
217 hProcess
= OpenProcess(PROCESS_SET_INFORMATION
, FALSE
, dwProcessId
);
221 GetLastErrorText(strErrorText
, 260);
222 LoadString(hInst
, IDS_MSG_UNABLECHANGEPRIORITY
, szTemp
, 256);
223 MessageBox(hMainWnd
, strErrorText
, szTemp
, MB_OK
|MB_ICONSTOP
);
227 if (!SetPriorityClass(hProcess
, NORMAL_PRIORITY_CLASS
))
229 GetLastErrorText(strErrorText
, 260);
230 LoadString(hInst
, IDS_MSG_UNABLECHANGEPRIORITY
, szTemp
, 256);
231 MessageBox(hMainWnd
, strErrorText
, szTemp
, MB_OK
|MB_ICONSTOP
);
234 CloseHandle(hProcess
);
237 void ProcessPage_OnSetPriorityBelowNormal(void)
243 TCHAR strErrorText
[260];
245 for (Index
=0; Index
<(ULONG
)ListView_GetItemCount(hProcessPageListCtrl
); Index
++)
247 memset(&lvitem
, 0, sizeof(LVITEM
));
249 lvitem
.mask
= LVIF_STATE
;
250 lvitem
.stateMask
= LVIS_SELECTED
;
251 lvitem
.iItem
= Index
;
253 ListView_GetItem(hProcessPageListCtrl
, &lvitem
);
255 if (lvitem
.state
& LVIS_SELECTED
)
259 dwProcessId
= PerfDataGetProcessId(Index
);
261 if ((ListView_GetSelectedCount(hProcessPageListCtrl
) != 1) || (dwProcessId
== 0))
264 LoadString(hInst
, IDS_MSG_WARNINGCHANGEPRIORITY
, szTemp
, 256);
265 LoadString(hInst
, IDS_MSG_TASKMGRWARNING
, szTempA
, 256);
266 if (MessageBox(hMainWnd
, szTemp
, szTempA
, MB_YESNO
|MB_ICONWARNING
) != IDYES
)
269 hProcess
= OpenProcess(PROCESS_SET_INFORMATION
, FALSE
, dwProcessId
);
273 GetLastErrorText(strErrorText
, 260);
274 LoadString(hInst
, IDS_MSG_UNABLECHANGEPRIORITY
, szTemp
, 256);
275 MessageBox(hMainWnd
, strErrorText
, szTemp
, MB_OK
|MB_ICONSTOP
);
279 if (!SetPriorityClass(hProcess
, BELOW_NORMAL_PRIORITY_CLASS
))
281 GetLastErrorText(strErrorText
, 260);
282 LoadString(hInst
, IDS_MSG_UNABLECHANGEPRIORITY
, szTemp
, 256);
283 MessageBox(hMainWnd
, strErrorText
, szTemp
, MB_OK
|MB_ICONSTOP
);
286 CloseHandle(hProcess
);
289 void ProcessPage_OnSetPriorityLow(void)
295 TCHAR strErrorText
[260];
297 for (Index
=0; Index
<(ULONG
)ListView_GetItemCount(hProcessPageListCtrl
); Index
++)
299 memset(&lvitem
, 0, sizeof(LVITEM
));
301 lvitem
.mask
= LVIF_STATE
;
302 lvitem
.stateMask
= LVIS_SELECTED
;
303 lvitem
.iItem
= Index
;
305 ListView_GetItem(hProcessPageListCtrl
, &lvitem
);
307 if (lvitem
.state
& LVIS_SELECTED
)
311 dwProcessId
= PerfDataGetProcessId(Index
);
313 if ((ListView_GetSelectedCount(hProcessPageListCtrl
) != 1) || (dwProcessId
== 0))
316 LoadString(hInst
, IDS_MSG_WARNINGCHANGEPRIORITY
, szTemp
, 256);
317 LoadString(hInst
, IDS_MSG_TASKMGRWARNING
, szTempA
, 256);
318 if (MessageBox(hMainWnd
, szTemp
, szTempA
, MB_YESNO
|MB_ICONWARNING
) != IDYES
)
321 hProcess
= OpenProcess(PROCESS_SET_INFORMATION
, FALSE
, dwProcessId
);
325 GetLastErrorText(strErrorText
, 260);
326 LoadString(hInst
, IDS_MSG_UNABLECHANGEPRIORITY
, szTemp
, 256);
327 MessageBox(hMainWnd
, strErrorText
, szTemp
, MB_OK
|MB_ICONSTOP
);
331 if (!SetPriorityClass(hProcess
, IDLE_PRIORITY_CLASS
))
333 GetLastErrorText(strErrorText
, 260);
334 LoadString(hInst
, IDS_MSG_UNABLECHANGEPRIORITY
, szTemp
, 256);
335 MessageBox(hMainWnd
, strErrorText
, szTemp
, MB_OK
|MB_ICONSTOP
);
338 CloseHandle(hProcess
);