标题:
[原创]发一段老早写的列举,结束进程的程序代码,perl写的.
[打印本页]
作者:
damnyou
时间:
2007-2-20 02:06
标题:
[原创]发一段老早写的列举,结束进程的程序代码,perl写的.
[watermark]发一段老早写的列举,结束进程的程序代码,perl写的.
#!perl -w
use Win32::Process;
use Win32::ToolHelp;
print " 进程管理工具
By Xtiger www.Xtiger.net\n-------------------------\n";
while(print qq/1、列举进程;\n2、结束进程;\n3、查询进程的绝对路径和加载的模块。\n想做什么:/)
{
$want=<stdin>;
chomp($want);
print "--------------\n";
if($want eq ';1';){getlist() and next;}
if($want eq ';2';){killpid() and next;}
if($want eq ';3';){modpid() and next;}
if($want<1 or $want>3){print "选择错误!\n";}
}
sub getlist
{
print "PID","\t","线程数","\t","名称","\n";
my @ps = Win32::ToolHelp::GetProcesses();
foreach my $p (@ps)
{ print $$p[1],"\t",$$p[4],"\t",$$p[8], "\n"; }
print "--------------\n";
}
sub killpid
{
print "请输入需要结束的进程的PID:";
$kpid=<stdin>;
chomp($kpid);
if($kpid eq "" or not $kpid=~/[\d.]/g)
{
print "没有正确输入PID\n";
goto nokill;
}
my $kill=Win32::Process::KillProcess($kpid,1);
if($kill==1)
{
print "\n成功结束进程!\n";
}
else
{
print "\n结束进程失败!\n";
}
nokill:
print "--------------\n";
}
sub modpid
{
print "请输入需要查询的进程的PID:";
$mpid=<stdin>;
chomp($mpid);
if($mpid eq "" or not $mpid=~/[\d.]/g)
{
print "没有正确输入PID\n";
goto nomod;
}
my @ms = Win32::ToolHelp::GetProcessModules($mpid);
foreach my $m (@ms)
{ print $$m[7],"\t",$$m[8],"\n"; }
nomod:
print "--------------\n";
}
复制代码
[/watermark]
作者:
adman
时间:
2007-2-21 10:09
标题:
[原创]发一段老早写的列举,结束进程的程序代码,perl写的.
学习学习!
作者:
花无缺
时间:
2007-3-17 12:26
学习...
欢迎光临 黑色海岸线论坛 (http://bbs.thysea.com/)
Powered by Discuz! 7.2