6 * Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
7 * Copyright (C) 2008 Vladimir Pankratov
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
32 #include "wine/unicode.h"
36 static WCHAR wszWarnMsg
[511];
37 static WCHAR wszWarnTitle
[255];
38 static WCHAR wszUnable2Terminate
[255];
40 static void load_message_strings(void)
42 LoadStringW(hInst
, IDS_TERMINATE_MESSAGE
, wszWarnMsg
, sizeof(wszWarnMsg
)/sizeof(WCHAR
));
43 LoadStringW(hInst
, IDS_TERMINATE_UNABLE2TERMINATE
, wszUnable2Terminate
, sizeof(wszUnable2Terminate
)/sizeof(WCHAR
));
44 LoadStringW(hInst
, IDS_WARNING_TITLE
, wszWarnTitle
, sizeof(wszWarnTitle
)/sizeof(WCHAR
));
47 void ProcessPage_OnEndProcess(void)
53 WCHAR wstrErrorText
[256];
55 load_message_strings();
57 Count
= SendMessageW(hProcessPageListCtrl
, LVM_GETITEMCOUNT
, 0, 0);
58 for (Index
=0; Index
<Count
; Index
++)
60 lvitem
.mask
= LVIF_STATE
;
61 lvitem
.stateMask
= LVIS_SELECTED
;
65 SendMessageW(hProcessPageListCtrl
, LVM_GETITEMW
, 0, (LPARAM
) &lvitem
);
67 if (lvitem
.state
& LVIS_SELECTED
)
71 Count
= SendMessageW(hProcessPageListCtrl
, LVM_GETSELECTEDCOUNT
, 0, 0);
72 dwProcessId
= PerfDataGetProcessId(Index
);
73 if ((Count
!= 1) || (dwProcessId
== 0))
76 if (MessageBoxW(hMainWnd
, wszWarnMsg
, wszWarnTitle
, MB_YESNO
|MB_ICONWARNING
) != IDYES
)
79 hProcess
= OpenProcess(PROCESS_TERMINATE
, FALSE
, dwProcessId
);
83 GetLastErrorText(wstrErrorText
, sizeof(wstrErrorText
)/sizeof(WCHAR
));
84 MessageBoxW(hMainWnd
, wstrErrorText
,wszUnable2Terminate
, MB_OK
|MB_ICONSTOP
);
88 if (!TerminateProcess(hProcess
, 0))
90 GetLastErrorText(wstrErrorText
, sizeof(wstrErrorText
)/sizeof(WCHAR
));
91 MessageBoxW(hMainWnd
, wstrErrorText
,wszUnable2Terminate
, MB_OK
|MB_ICONSTOP
);
94 CloseHandle(hProcess
);
97 void ProcessPage_OnEndProcessTree(void)
103 WCHAR wstrErrorText
[256];
105 load_message_strings();
107 Count
= SendMessageW(hProcessPageListCtrl
, LVM_GETITEMCOUNT
, 0, 0);
108 for (Index
=0; Index
<Count
; Index
++)
110 lvitem
.mask
= LVIF_STATE
;
111 lvitem
.stateMask
= LVIS_SELECTED
;
112 lvitem
.iItem
= Index
;
115 SendMessageW(hProcessPageListCtrl
, LVM_GETITEMW
, 0, (LPARAM
) &lvitem
);
117 if (lvitem
.state
& LVIS_SELECTED
)
121 Count
= SendMessageW(hProcessPageListCtrl
, LVM_GETSELECTEDCOUNT
, 0, 0);
122 dwProcessId
= PerfDataGetProcessId(Index
);
123 if ((Count
!= 1) || (dwProcessId
== 0))
126 if (MessageBoxW(hMainWnd
, wszWarnMsg
, wszWarnTitle
, MB_YESNO
|MB_ICONWARNING
) != IDYES
)
129 hProcess
= OpenProcess(PROCESS_TERMINATE
, FALSE
, dwProcessId
);
133 GetLastErrorText(wstrErrorText
, sizeof(wstrErrorText
)/sizeof(WCHAR
));
134 MessageBoxW(hMainWnd
, wstrErrorText
,wszUnable2Terminate
, MB_OK
|MB_ICONSTOP
);
138 if (!TerminateProcess(hProcess
, 0))
140 GetLastErrorText(wstrErrorText
, sizeof(wstrErrorText
)/sizeof(WCHAR
));
141 MessageBoxW(hMainWnd
, wstrErrorText
,wszUnable2Terminate
, MB_OK
|MB_ICONSTOP
);
144 CloseHandle(hProcess
);