昏倒,谁能注解下这段代码,......
网上看到的:int killpro(string a)
{
cout<<a;
PROCESSENTRY32 pe32;
pe32.dwSize =sizeof(pe32);
HANDLE hpro=::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
if(hpro==INVALID_HANDLE_VALUE)
{
cout<<"call function failed\n";
return 0;
}
BOOL nowrun=Process32First(hpro,&pe32);
while(nowrun)
{
if(pe32.szExeFile ==a)
{
DWORD proid=pe32.th32ProcessID;
HANDLE hprocess=::OpenProcess(PROCESS_ALL_ACCESS,FALSE,proid);
if(hprocess!=NULL)
{
::TerminateProcess(hprocess,0);
::CloseHandle(hprocess);
}
}
nowrun=::Process32Next(hpro,&pe32);
}
}
字符串A是当前进程的程序名,它的功能是结束程序.
麻烦对各行做个注解吧...........