怎样用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);
reliablesite怎么样?reliablesite是一家于2006年成立的老牌美国主机商,主要提供独服,数据中心有迈阿密、纽约、洛杉矶等,均免费提供20Gbps DDoS防护,150TB月流量,1Gbps带宽。月付19美金可升级为10Gbps带宽。洛杉矶/纽约/迈阿密等机房,E3-1240V6/64GB内存/1TB SSD硬盘/DDOS/150TB流量/1Gbps带宽/DDOS,$95/月,...
我们先普及一下常识吧,每年9月的第一个星期一是美国劳工节。于是,有一些服务商会基于这些节日推出吸引用户的促销活动,比如RackNerd有推出四款洛杉矶和犹他州独立服务器,1G带宽、5个独立IP地址,可以配置Windows和Linux系统,如果有需要独立服务器的可以看看。第一、劳工节促销套餐这里有提供2个套餐。两个方案是选择犹他州的,有2个方案是可以选择洛杉矶机房的。CPU内存SSD硬盘配置流量价格...
racknerd怎么样?racknerd今天发布了几款美国特价独立服务器的促销,本次商家主推高配置的服务器,各个配置给的都比较高,有Intel和AMD两种,硬盘也有NVMe和SSD等多咱组合可以选择,机房目前有夏洛特、洛杉矶、犹他州可以选择,性价比很高,有需要独服的朋友可以看看。点击进入:racknerd官方网站RackNerd暑假独服促销:CPU:双E5-2680v3 (24核心,48线程)内存...
processentry32为你推荐
数据库连接怎么链接数据库trapezoid人体各个骨头的英文单词免费erp最方便使用的免费erp软件有哪些初始化磁盘win10新装硬盘初始化?ucosiiucosii操作系统能运行什么软件豆瓣fm电台豆瓣和蜻蜓fmlinux安装教程怎么装LINUX的系统....实数的定义实数的概念是什么,实数包括0吗?阶乘函数C语言中有计算阶乘的函数吗 不是自己写,,,是那种可以直接调用的函数手机壳生产厂家寻找制作手机壳的厂家有哪些?
空间租用 上海域名注册 国外免费vps sugarhosts 日本软银 赵容 oneasiahost siteground diahosting 免费ddos防火墙 全能主机 150邮箱 免费网站申请 adroit 卡巴斯基免费试用 搜索引擎提交入口 vip域名 上海联通宽带测速 联通网站 四川电信商城 更多