老样子直接上代码
#include<iostream>
#include<Windows.h>
#include <tlhelp32.h>
using namespace std;
bool getProcess(const char *procressName)
{
cout<<"欢迎使用LZZ开发工具:BBJY!!!";
Sleep(1000);
system("cls");
char pName[MAX_PATH];
strcpy(pName,procressName);
CharLowerBuff(pName,MAX_PATH);
PROCESSENTRY32 currentProcess;
currentProcess.dwSize = sizeof(currentProcess);
HANDLE hProcess = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
if (hProcess == INVALID_HANDLE_VALUE)
{
cout<<"失败,请重新运行程序!!!";
return false;
}
bool bMore=Process32First(hProcess,¤tProcess);
while(bMore)
{
CharLowerBuff(currentProcess.szExeFile,MAX_PATH);
if (strcmp(currentProcess.szExeFile,pName)==0)
{
CloseHandle(hProcess);
return true;
}
bMore=Process32Next(hProcess,¤tProcess);
}
CloseHandle(hProcess);
return false;
}
int main()
{
if (getProcess("StudentMain.exe"))
{
system("TASKKILL /F /IM StudentMain.exe /T");
system("TASKKILL /F /IM ProcHelper64.exe /T");
cout<<"BYE BYE JIYU!!!";
Sleep(3000);
}
else
{
cout<<"找不到极域的进程!";
}
return 0;
}