怎样用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);
NameCheap商家如今发布促销活动也是有不小套路的,比如会在提前一周+的时间告诉你他们未来的活,比如这次2021年的首次活动就有在一周之前看到,但是这不等到他们中午一点左右的时候才有正式开始,而且我确实是有需要注册域名,等着看看是否有真的折扣,但是实际上.COM域名力度也就一般需要51元左右,其他地方也就55元左右。当然,这次新年的首次活动不管如何肯定是比平时便宜一点点的。有新注册域名、企业域...
pigyun怎么样?PIGYunData成立于2019年,2021是PIGYun为用户提供稳定服务的第三年,目前商家提供香港CN2线路、韩国cn2线路、美西CUVIP-9929、GIA等线路优质VPS,基于KVM虚拟架构,商家采用魔方云平台,所有的配置都可以弹性选择,目前商家推出了七月优惠,韩国和美国所有线路都有相应的促销,六折至八折,性价比不错。点击进入:PIGYun官方网站地址PIGYUN优惠...
最近AS9929线路比较火,联通A网,对标电信CN2,HostYun也推出了走联通AS9929线路的VPS主机,基于KVM架构,开设在洛杉矶机房,采用SSD硬盘,分为入门和高带宽型,最高提供500Mbps带宽,可使用9折优惠码,最低每月仅18元起。这是一家成立于2008年的VPS主机品牌,原主机分享组织(hostshare.cn),商家以提供低端廉价VPS产品而广为人知,是小成本投入学习练手首选。...
processentry32为你推荐
蓝屏代码windows 系统蓝屏代码多少?微指数做微商怎么像别人推荐自己?trapezoidtearing strength是什么意思seasonalseasonal greetings中文什么意思app退款appstore充值后怎么退款scanf返回值scanf 的返回值豆瓣fm电台豆瓣怎么听音乐电子听诊器听诊器有哪些用途的知识蓝牙开发android 蓝牙开发 ble 难吗讯飞tts有用过科大讯飞TTS语音合成系统的吗
域名抢注 花生壳动态域名 免费试用vps 如何申请免费域名 阿云浏览器 locvps bluevm stablehost iisphpmysql 免费个人博客 腾讯云分析 炎黄盛世 河南m值兑换 服务器合租 重庆双线服务器托管 国外ip加速器 上海联通宽带测速 Updog 四川电信商城 web服务器是什么 更多