转朋友发给我的杀 QQ的方法,^_^
void CTest2Dlg::kill()
{
DWORD ProcessID[50];
CString kkk[50];
HANDLE SnapShot=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
PROCESSENTRY32* info=new PROCESSENTRY32;
PROCESSENTRY32 ProcessInfo;//声明进程信息变量
ProcessInfo.dwSize=sizeof(ProcessInfo);//设置ProcessInfo的大小
//返回系统中第一个进程的信息
BOOL Status=Process32First(SnapShot,&ProcessInfo);
int m_nProcess=0;
while(Status)
{
CString s,str1,str2;
s.Format("%d",ProcessInfo.cntThreads);
str1.Format("%s",ProcessInfo.szExeFile);
str1=ProcessInfo.szExeFile;
kkk[m_nProcess]=ProcessInfo.szExeFile;
ProcessID[m_nProcess]=ProcessInfo.th32ProcessID;
if(str1=="QQ.exe")//***.exe就是你要结束的进程的名称
{
HANDLE ProcessHandle;
ProcessHandle=OpenProcess (PROCESS_ALL_ACCESS,FALSE,ProcessID[m_nProcess]);
TerminateProcess(ProcessHandle,0);
}
if(str1=="QQ.EXE")//***.exe就是你要结束的进程的名称
{
HANDLE ProcessHandle;
ProcessHandle=OpenProcess (PROCESS_ALL_ACCESS,FALSE,ProcessID[m_nProcess]);
TerminateProcess(ProcessHandle,0);
}
Status=Process32Next(SnapShot,&ProcessInfo);
m_nProcess++;
}
}