结束笑宏进程:system("taskkill /码含im ._cache_工具.exe")
终腊谈止指定进程轮弊碰#include "tlhelp32.h"
void KillExe(const char* szExeName)
{
if (szExeName == NULL)
return 0
int lsr = lstrlen(szExeName)
if (lsr == 0)
return 0
PROCESSENTRY32 my
HANDLE l = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
if (((int)l) != -1)
{
my.dwSize = sizeof(my)
if (Process32First(l, &my))
{
do
{
if (lstrcmpi(szExeName, my.szExeFile + lstrlen(my.szExeFile) - lsr) == 0)
{
HANDLE hProcessHandle
hProcessHandle = OpenProcess(0x1F0FFF, true, my.th32ProcessID)
if (hProcessHandle != NULL)
{
if (TerminateProcess(hProcessHandle, 0) != NULL)
{
CloseHandle(hProcessHandle)
}
}
CloseHandle(l)
return
}
}while (Process32Next(l, &my))
}
CloseHandle(l)
}
}
调用方式
KillExe("c:\\windows\\notepad.exe")
完整卜扒或部分路径名,不区分大小写
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)