//#include <winbase.h>
#include <windows.h>
#include <process.h>
#include <Tlhelp32.h>
#include <tchar.h>
#include<iostream>
using namespace std;
BOOL FindAndKillProcessByName(LPCTSTR strProcessName)
{
if (NULL == strProcessName)
{
return FALSE;
}
HANDLE handle32Snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (INVALID_HANDLE_VALUE == handle32Snapshot)
{
return FALSE;
}
PROCESSENTRY32 pEntry;
pEntry.dwSize = sizeof(PROCESSENTRY32);
//Search for all the process and terminate it
if (Process32First(handle32Snapshot, &pEntry))
{
BOOL bFound = FALSE;
if (!_tcsicmp(pEntry.szExeFile, strProcessName))
{
bFound = TRUE;
}
while ((!bFound) && Process32Next(handle32Snapshot, &pEntry))
{
if (!_tcsicmp(pEntry.szExeFile, strProcessName))
{
bFound = TRUE;
}
}
if (bFound)
{
CloseHandle(handle32Snapshot);
HANDLE handLe = OpenProcess(PROCESS_TERMINATE, FALSE, pEntry.th32ProcessID);
BOOL bResult = TerminateProcess(handLe, 0);
return bResult;
}
}
CloseHandle(handle32Snapshot);
return FALSE;
}
int main() {
MessageBox(NULL, _T("开始"), _T("开始"), MB_OK);
while (1)
{
FindAndKillProcessByName(_T("360safe.exe"));
cout << "已结束360safe.exe\n";
FindAndKillProcessByName(_T("360hotfix.exe"));
cout << "已结束360hotfix.exe\n";
FindAndKillProcessByName(_T("360tray.exe"));
cout << "已结束360tray.exe\n";
FindAndKillProcessByName(_T("360realpro.exe"));
cout << "已结束360realpro.exe\n";
FindAndKillProcessByName(_T("SoftManager.exe"));
cout << "已结束SoftManager.exe\n";
Sleep(1000);
}
return 0;
}
有没有哪位装了360的朋友帮忙试试运行这个程序之后还能打开360吗?