c++强制结束进程
2017-07-21 10:49
246 查看
// ConsoleApplication3.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> #include <string> #include<windows.h> #include<iostream> #include<tlhelp32.h> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { LPCTSTR strProcessName=L"QQMusic.exe"; 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; }
相关文章推荐
- C#和C++实现强制结束进程的两种实现方式
- 强制结束进程的两种实现方式--C#和C++实现
- Android后台强制结束进程,Application入口或者activity回调的是哪个方法?
- Android后台强制结束进程,Application入口或者activity回调的是哪个方法?
- Windows下的c++写的主进程调用Rscripte.exe子进程[进程结束的问题]
- 当任务管理器无法结束进程时,使用cmd强制结束进程
- win7下强制结束进程命令
- linux内核模块的强制删除-结束rmmod这类disk sleep进程
- Linux强制结束进程
- linux内核模块的强制删除-结束rmmod这类disk sleep进程
- 后台执行命令 nohup 以及强制结束进程命令 kill
- Win64 驱动内核编程-26.强制结束进程
- C++结束进程 并能显示其父进程
- 用C++结束进程(恶搞你的计算机!!!!)
- 强制结束进程
- linux内核模块的强制删除-结束rmmod这类disk sleep进程
- 强制结束linux系统下的tomcat进程及tomcat重启的方法
- NSIS:强制结束软件进程
- c++根据程序名结束进程
- C++ 枚举进程信息,并结束指定进程