~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/programs/taskmgr/endproc.c

Version: ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  *  ReactOS Task Manager
  3  *
  4  *  endproc.c
  5  *
  6  *  Copyright (C) 1999 - 2001  Brian Palmer  <brianp@reactos.org>
  7  *  Copyright (C) 2008  Vladimir Pankratov
  8  *
  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.
 13  *
 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.
 18  *
 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
 22  */
 23     
 24 #define WIN32_LEAN_AND_MEAN    /* Exclude rarely-used stuff from Windows headers */
 25 #include <windows.h>
 26 #include <commctrl.h>
 27 #include <stdlib.h>
 28 #include <memory.h>
 29 #include <stdio.h>
 30 #include <winnt.h>
 31 
 32 #include "wine/unicode.h"
 33 #include "taskmgr.h"
 34 #include "perfdata.h"
 35 
 36 WCHAR    wszWarnMsg[511];
 37 WCHAR    wszWarnTitle[255];
 38 WCHAR    wszUnable2Terminate[255];
 39 
 40 static void load_message_strings(void)
 41 {
 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));
 45 }
 46 
 47 void ProcessPage_OnEndProcess(void)
 48 {
 49     LVITEMW          lvitem;
 50     ULONG            Index;
 51     DWORD            dwProcessId;
 52     HANDLE           hProcess;
 53     WCHAR            wstrErrorText[256];
 54 
 55     load_message_strings();
 56 
 57     for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
 58     {
 59         lvitem.mask = LVIF_STATE;
 60         lvitem.stateMask = LVIS_SELECTED;
 61         lvitem.iItem = Index;
 62         lvitem.iSubItem = 0;
 63 
 64         SendMessageW(hProcessPageListCtrl, LVM_GETITEMW, 0, (LPARAM) &lvitem);
 65 
 66         if (lvitem.state & LVIS_SELECTED)
 67             break;
 68     }
 69 
 70     dwProcessId = PerfDataGetProcessId(Index);
 71 
 72     if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
 73         return;
 74 
 75     if (MessageBoxW(hMainWnd, wszWarnMsg, wszWarnTitle, MB_YESNO|MB_ICONWARNING) != IDYES)
 76         return;
 77 
 78     hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwProcessId);
 79 
 80     if (!hProcess)
 81     {
 82         GetLastErrorText(wstrErrorText, sizeof(wstrErrorText)/sizeof(WCHAR));
 83         MessageBoxW(hMainWnd, wstrErrorText,wszUnable2Terminate, MB_OK|MB_ICONSTOP);
 84         return;
 85     }
 86 
 87     if (!TerminateProcess(hProcess, 0))
 88     {
 89         GetLastErrorText(wstrErrorText, sizeof(wstrErrorText)/sizeof(WCHAR));
 90         MessageBoxW(hMainWnd, wstrErrorText,wszUnable2Terminate, MB_OK|MB_ICONSTOP);
 91     }
 92 
 93     CloseHandle(hProcess);
 94 }
 95 
 96 void ProcessPage_OnEndProcessTree(void)
 97 {
 98     LVITEMW          lvitem;
 99     ULONG            Index;
100     DWORD            dwProcessId;
101     HANDLE           hProcess;
102     WCHAR            wstrErrorText[256];
103 
104     load_message_strings();
105 
106     for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
107     {
108         lvitem.mask = LVIF_STATE;
109         lvitem.stateMask = LVIS_SELECTED;
110         lvitem.iItem = Index;
111         lvitem.iSubItem = 0;
112 
113         SendMessageW(hProcessPageListCtrl, LVM_GETITEMW, 0, (LPARAM) &lvitem);
114 
115         if (lvitem.state & LVIS_SELECTED)
116             break;
117     }
118 
119     dwProcessId = PerfDataGetProcessId(Index);
120 
121     if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
122         return;
123 
124     if (MessageBoxW(hMainWnd, wszWarnMsg, wszWarnTitle, MB_YESNO|MB_ICONWARNING) != IDYES)
125         return;
126 
127     hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwProcessId);
128 
129     if (!hProcess)
130     {
131         GetLastErrorText(wstrErrorText, sizeof(wstrErrorText)/sizeof(WCHAR));
132         MessageBoxW(hMainWnd, wstrErrorText,wszUnable2Terminate, MB_OK|MB_ICONSTOP);
133         return;
134     }
135 
136     if (!TerminateProcess(hProcess, 0))
137     {
138         GetLastErrorText(wstrErrorText, sizeof(wstrErrorText)/sizeof(WCHAR));
139         MessageBoxW(hMainWnd, wstrErrorText,wszUnable2Terminate, MB_OK|MB_ICONSTOP);
140     }
141 
142     CloseHandle(hProcess);
143 }
144 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.