怎样用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);
RAKsmart怎么样?RAKsmart香港机房新增了付费的DDoS高防保护服务,香港服务器默认接入20Mbps的大陆优化带宽(电信走CN2、联通和移动走BGP)。高防服务器需要在下单页面的IP Addresses Option里面选择购买,分:40Gbps大陆优化高防IP-$461/月、100Gbps国际BGP高防IP-$692/月,有兴趣的可以根据自己的需求来选择!点击进入:RAKsmart官...
农历春节将至,腾讯云开启了热门爆款云产品首单特惠秒杀活动,上海/北京/广州1核2G云服务器首年仅38元起,上架了新的首单优惠活动,每天三场秒杀,长期有效,其中轻量应用服务器2G内存5M带宽仅需年费38元起,其他产品比如CDN流量包、短信包、MySQL、直播流量包、标准存储等等产品也参与活动,腾讯云官网已注册且完成实名认证的国内站用户均可参与。活动页面:https://cloud.tencent.c...
小白云是一家国人自营的企业IDC,主营国内外VPS,致力于让每一个用户都能轻松、快速、经济地享受高端的服务,成立于2019年,拥有国内大带宽高防御的特点,专注于DDoS/CC等攻击的防护;海外线路精选纯CN2线路,以确保用户体验的首选线路,商家线上多名客服一对一解决处理用户的问题,提供7*24无人全自动化服务。商家承诺绝不超开,以用户体验为中心为用提供服务,一直坚持主打以产品质量用户体验性以及高效...
processentry32为你推荐
免费erp免费ERP靠谱吗?sap是什么SAP是什么东西apple以旧换新苹果以旧换新真的吗?密码设置电脑怎么设置密码diskgenius免费版给我发一个 DISKGenius恢复数据破解版的可以吗,或者其他破解版的也可以,只要能恢复数据,感激不尽,...最好的视频播放器目前最好的视频播放器是什么?系统登录界面电脑用户登录界面,输入密码登不进去了,怎么解决,急色温图色温是什么意思?色温图表qsv视频格式转换器QSV格式的视频用什么格式转换器可以转换?微店是什么微店和微商有什么区别呢
虚拟主机是什么 网址域名注册 电信服务器租用 域名查询工具 google镜像 国外服务器网站 国内永久免费云服务器 云全民 美国十次啦服务器 php空间申请 中国电信测网速 免费申请个人网站 天翼云盘 爱奇艺vip免费领取 新睿云 服务器是干什么用的 空间登陆首页 中国电信测速器 空间申请 免费主页空间 更多