3 * Copyright (C) 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS kill.exe
22 * FILE: apps/utils/kill/kill.c
23 * PURPOSE: Kill a running Process
24 * PROGRAMMER: Steven Edwards (Steven_Ed4153@yahoo.com)
27 /* Thanks to David, Capser, Eric and others for the example code
28 * from the old shell.exe
31 #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
37 ExecuteKill(char * lpPid
)
42 dwProcessId
= (DWORD
) atol(lpPid
);
43 fprintf( stderr
, "Killing PID %ld...\n",dwProcessId
);
44 hProcess
= OpenProcess(
51 fprintf( stderr
, "Could not open the process with PID = %ld\n", dwProcessId
);
54 if (FALSE
== TerminateProcess(
59 fprintf( stderr
, "Could not terminate the process with PID = %ld\n", dwProcessId
);
62 CloseHandle(hProcess
);
66 int main(int argc
, char *argv
[])
69 DBG_UNREFERENCED_LOCAL_VARIABLE(tail
);
73 fprintf( stderr
, "Usage: %s PID (Process ID) \n", argv
[0] );
76 tail
= ExecuteKill(argv
[1]);