1, according to the process name to end the corresponding process, exe name: "__killprocessbyname_console_vc6.exe".
Project saved in Baidu Cloud (CodeSkill33)--All Files-->util_ My gadget _ small software--> VS08_VC6---Process Name _ Enumeration Process _ End process--__ killprocessbyname_console_vc6__?????. RAR
2. Code:
//__killprocessbyname_console_vc6.cpp:defines the entry point for the console application.//#include"stdafx.h"#include<stdlib.h>#include<stdio.h>#include<windows.h>#include<TlHelp32.h>BOOLMatchprocessname (Char* _pcprocnamesnapshot,intargcChar* argv[],int*_piidxout) { for(intI=1; i<argc; i++) { //strncmp are case-most grateful.//and a strcmp . if(!strnicmp (_pcprocnamesnapshot, Argv[i], strlen (Argv[i])) { *_piidxout =i; return true; } } return false;}intMainintargcChar*argv[]) { if(ARGC <2) {printf ("In the program's command-line arguments, enter the name of the process that requires kill \ n"); return 0; } printf ("The name of the process you want to end is: \ n"); for(intI=1; i<argc; i++) {printf ("\t%s\n", Argv[i]); } printf ("Press any key to continue, or close this window to exit the program \ n"); System ("Pause"); int*pikills =New int[ARGC]; memset (Pikills,0, ARGC *sizeof(int));//ZC: Enumerating ProcessesHANDLE hsnapshot = CreateToolhelp32Snapshot (th32cs_snapprocess,0); PROCESSENTRY32 processEntry32= {0}; Processentry32.dwsize=sizeof(PROCESSENTRY32); BOOL bOk= Process32First (hSnapShot, &processEntry32); while(bOk) {//wprintf (L "%ws,%d\n", Processentry32.szexefile, Processentry32.th32processid); intIIDX =0; if(Matchprocessname (Processentry32.szexefile, argc, argv, &iIdx)) {DWORD ProcessID=Processentry32.th32processid; //Break ; //ZC: Forced End Process { //strcmp Wide character version wcscmp: Compare strings (case sensitive)//_stricmp Wide character version _wcsicmp: Comparing strings (case insensitive)HANDLE hprocess = OpenProcess (Process_terminate,false, ProcessID); if(hprocess = =NULL) {printf ("openprocess err:%d\n",:: GetLastError ()); System ("Pause"); } Else{BOOL Bresult= TerminateProcess (hprocess,0); if(!bresult) {printf ("terminateprocess err:%d\n",:: GetLastError ()); System ("Pause"); } Else{Pikills[iidx]++; } }}} bOk= Process32Next (hSnapShot, &processEntry32); }:: CloseHandle (hSnapShot); for(intj=1; j<argc; J + +) {printf ("\t%s was killed. \t==>%d processes \ n", Argv[j], pikills[j]); } System ("Pause"); return 0;}
3.
4.
5.
C + + gadgets. Close process