怎样用C语言编写代码结束一个已运行的软件 如迅雷 QQ等
传入参数strKillProcessName为进程名
#include "Tlhelp32.h"
void KillProcess(const CString& strKillProcessName)
{
HANDLE hSnapShot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
PROCESSENTRY32 processInfo;
processInfo.dwSize = sizeof( PROCESSENTRY32 );
BOOL bGetProcess = Process32First( hSnapShot, &processInfo );
while( bGetProcess )
{
CString strProcessName (processInfo.szExeFile);
if( strKillProcessName.CompareNoCase( strProcessName ) == 0 )
{
DWORD dwProcessID = processInfo.th32ProcessID;
HANDLE hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, dwProcessID );
if( hProcess != NULL )
{
TerminateProcess( hProcess, 0 );
CloseHandle(hProcess);
}
break;
}
bGetProcess = Process32Next( hSnapShot, &processInfo );
}
CloseHandle(hSnapShot);
}求详细介绍Process32First这个API函数及其参数的用法
Process32First FunctionRetrieves information about the first process encountered in a system snapshot.BOOL WINAPI Process32First( __in HANDLE hSnapshot, __in_out LPPROCESSENTRY32 lppe);ParametershSnapshot A handle to the snapshot returned from a previous call to the CreateToolhelp32Snapshot function.lppe A pointer to a PROCESSENTRY32 structure. It contains process information such as the name of the executable file, the process identifier, and the process identifier of the parent process.Return ValueReturns TRUE if the first entry of the process list has been copied to the buffer or FALSE otherwise. The ERROR_NO_MORE_FILES error value is returned by the GetLastError function if no processes exist or the snapshot does not contain process information.RemarksThe calling application must set the dwSize member of PROCESSENTRY32 to the size, in bytes, of the structure. To retrieve information about other processes recorded in the same snapshot, use the Process32Next function.如何在 MFC 中使用 CreateToolHelp32Snapshot 函数 ??...
请先#include <tlhelp32.h>
然后
PROCESSENTRY32 pe32 = { sizeof(pe32) };
HANDLE hSnapshot = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if(Process32First(hSnapshot, &pe){
do
{
// 这里是你想做的事
}
while(Process32Next(hSnapshot, &pe));
枚举模块
MODULEENTRY32 me32 = { sizeof(me32) };
HANDLE hSnapshot = ::CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, PID); // PID 进程ID
if(Module32First(hSnapshot, &pe){
do
{
// 这里是你想做的事
}
while(Module32Next(hSnapshot, &pe));win32 API函数 急急
可以VC有个Process32First函数可以参考一下
PROCESSENTRY32 pe32;
pe32.dwSize=sizeof(pe32);
int count=0;
HANDLE hProcessSnap=::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
if(hProcessSnap==INVALID_HANDLE_VALUE)
{
printf("CreateToolhelp32Snapshot调用失败!");
return -1;
}
BOOL bMore=::Process32First(hProcessSnap,&pe32);
printf("%20s %10s
","进程名","PID");
printf("====================================
");
while(bMore)
{
count++;
printf("%20s %10d
",pe32.szExeFile,pe32.th32ProcessID);//szExeFile就是包含路径
bMore=::Process32Next(hProcessSnap,&pe32);
}
用完CloseToolhelp32Snapshot(hProcessSnap);
bluehost怎么样?bluehost推出新一代VPS美国云主机!前几天,BlueHost也推出了对应的周年庆活动,全场海外虚拟主机月付2.95美元起,年付送免费的域名和SSL证书,通过活动进入BlueHost中文官网,购买虚拟主机、云虚拟主机和独立服务器参与限时促销。今天,云服务器网(yuntue.com)小编给大家介绍的是新一代VPS美国云主机,美国SSD云主机,2核2G/20GB空间,独立...
目前在标准互联这边有两台香港云服务器产品,这不看到有通知到期提醒才关注到。平时我还是很少去登录这个服务商的,这个服务商最近一年的促销信息比较少,这个和他们的运营策略有关系。已经从开始的倾向低价和个人用户云服务器市场,开始转型到中高端个人和企业用户的独立服务器。在这篇文章中,有看到标准互联有推出襄阳电信高防服务器100GB防御。有三款促销方案我们有需要可以看看。我们看看几款方案配置。型号内存硬盘IP...
imidc对日本独立服务器在搞特别促销,原价159美元的机器现在只需要88美元,而且给13个独立IPv4,30Mbps直连带宽,不限制流量。注意,本次促销只有一个链接,有2个不同的优惠码,你用不同的优惠码就对应着不同的配置,价格也不一样。88美元的机器,下单后默认不管就给512G SSD,要指定用HDD那就发工单,如果需要多加一个/28(13个)IPv4,每个月32美元...官方网站:https:...
processentry32为你推荐
php开发工具php开发工具有哪些codereview怎么样让代码走查做起来?trapezoid梯形的上底下底和腰的定义是什么?初始化磁盘win7系统如何磁盘初始化?qsv视频格式转换器如何免费把qsv格式转换为mp4格式spinmaster街球名人都有哪些廖华100个成语典故及其历史人物故事 南京廖华移动硬盘提示格式化移动硬盘打不开,提示需要格式化无线呼叫系统无线呼叫器怎么设置东芝官方网站东芝t130u是东芝旗下的产品吗,看到淘宝上有卖,但东芝官方网上 没有那一款产品,是山寨?硬盘
域名注册服务 域名停靠 网通服务器租用 广州主机租用 国外vps租用 中文域名申请 com域名抢注 仿牌空间 香港加速器 oneasiahost wdcp sub-process 日本空间 圣诞节促销 qq数据库 灵动鬼影 有益网络 服务器干什么用的 天翼云盘 超级服务器 更多