怎样用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);
rangcloud怎么样?rangcloud是去年年初开办的国人商家,RangCloud是一家以销售NAT起步,后续逐渐开始拓展到VPS及云主机业务,目前有中国香港、美国西雅图、韩国NAT、广州移动、江门移动、镇江BGP、山东联通、山东BGP等机房。目前,RangCloud提供香港CN2线路云服务器,电信走CN2、联通移动直连,云主机采用PCle固态硬盘,19.8元/月起,支持建站使用;美国高防云...
wordpress高级企业自适应主题,通用型企业展示平台 + 流行宽屏设计,自适应PC+移动端屏幕设备,完美企业站功能体验+高效的自定义设置平台。一套完美自适应多终端移动屏幕设备的WordPress高级企业自适应主题, 主题设置模块包括:基本设置、首页设置、社会化网络设置、底部设置、SEO设置; 可以自定义设置网站通用功能模块、相关栏目、在线客服及更多网站功能。点击进入:wordpress高级企业...
gcorelabs怎么样?gcorelabs是创建于2011年的俄罗斯一家IDC服务商,Gcorelabs提供优质的托管服务和VPS主机服务,Gcorelabs有一支强大的技术队伍,对主机的性能和稳定性要求非常高。Gcorelabs在 2017年收购了SkyparkCDN并提供全球CDN服务,目标是进入全球前五的网络服务商。G-Core Labs总部位于卢森堡,在莫斯科,明斯克和彼尔姆设有办事处。...
processentry32为你推荐
codereviewios有什么好的代码reviewscanf返回值scanf() 函数也有返回值?横幅广告通栏广告 横幅广告是什么意思免杀远控求一款好使(免杀)远程控制软件?比特币官方客户端bitcoin cash(BCC)是什么wifi快速破解器电脑版wifi万能钥匙电脑版怎么破解密码程序员段子有哪些好笑的关于程序员的笑话廖华100个成语典故及其历史人物故事 南京廖华移动硬盘提示格式化救命啊!移动硬盘一直提示让我格式化,里面有很多重要数据啊```tplink端口映射TP-link 怎样设置内网端口映射
如何注册网站域名 如何申请免费域名 132邮箱 美国主机评论 uk2 tier 抢票工具 灵动鬼影 坐公交投2700元 个人域名 双线主机 南通服务器 厦门电信 什么是web服务器 新加坡空间 lamp架构 云服务是什么意思 亿库 塔式服务器 web服务器有哪些 更多