mirror of https://github.com/lianthony/NT4.0
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
2.2 KiB
107 lines
2.2 KiB
/*++
|
|
|
|
Copyright (c) 1992-1996 Microsoft Corporation
|
|
|
|
Module Name:
|
|
|
|
snmptst7.c
|
|
|
|
Abstract:
|
|
|
|
Utility to terminate a process.
|
|
|
|
Environment:
|
|
|
|
User Mode - Win32
|
|
|
|
Revision History:
|
|
|
|
10-May-1996 DonRyan
|
|
Removed banner from Technology Dynamics, Inc.
|
|
|
|
--*/
|
|
|
|
//--------------------------- WINDOWS DEPENDENCIES --------------------------
|
|
|
|
#include <windows.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
//--------------------------- STANDARD DEPENDENCIES -- #include<xxxxx.h> ----
|
|
|
|
//--------------------------- MODULE DEPENDENCIES -- #include"xxxxx.h" ------
|
|
|
|
//--------------------------- SELF-DEPENDENCY -- ONE #include"module.h" -----
|
|
|
|
//--------------------------- PUBLIC VARIABLES --(same as in module.h file)--
|
|
|
|
//--------------------------- PRIVATE CONSTANTS -----------------------------
|
|
|
|
//--------------------------- PRIVATE STRUCTS -------------------------------
|
|
|
|
//--------------------------- PRIVATE VARIABLES -----------------------------
|
|
|
|
//--------------------------- PRIVATE PROTOTYPES ----------------------------
|
|
|
|
//--------------------------- PRIVATE PROCEDURES ----------------------------
|
|
|
|
//--------------------------- PUBLIC PROCEDURES -----------------------------
|
|
|
|
int _CRTAPI1 main(
|
|
int argc,
|
|
char *argv[])
|
|
{
|
|
DWORD pid;
|
|
HANDLE hProcess;
|
|
|
|
if (argc == 1)
|
|
{
|
|
printf("Error: No arguments specified.\n", *argv);
|
|
printf("\nusage: kill <pid>\n");
|
|
|
|
return 1;
|
|
}
|
|
|
|
while(--argc)
|
|
{
|
|
DWORD temp;
|
|
|
|
argv++;
|
|
|
|
if (1 == sscanf(*argv, "%x", &temp))
|
|
{
|
|
pid = temp;
|
|
}
|
|
else
|
|
{
|
|
printf("Error: Argument %s is invalid.\n", *argv);
|
|
printf("\nusage: kill <pid>\n");
|
|
|
|
return 1;
|
|
}
|
|
} // end while()
|
|
|
|
|
|
if ((hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid)) == NULL)
|
|
{
|
|
printf("Error: OpenProcess %d\n", GetLastError());
|
|
|
|
return 1;
|
|
}
|
|
|
|
if (!TerminateProcess(hProcess, 0))
|
|
{
|
|
printf("Error: TerminateProcess %d\n", GetLastError());
|
|
|
|
return 1;
|
|
}
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
//-------------------------------- END --------------------------------------
|
|
|
|
|