随笔 - 110  文章 - 28 评论 - 26 

留言簿(1)

随笔分类(103)

随笔档案(110)

文章分类(25)

文章档案(28)

新闻档案(3)

友情连接

  • 小蜜蜂
  • 马氏膏药网
  • 淋巴结肿大,淋巴结核,淋巴结炎 乳腺增生,小叶增生 颈椎病,腰椎病,腰间盘突出 马氏淋巴消炎贴,马氏增生散结贴,马氏关节肌肉贴
  • 黑客基地
  • 全球最大的黑客门户网站

最新随笔

积分与排名

  • 积分 - 143629
  • 排名 - 44

最新评论

阅读排行榜

评论排行榜

新建窗体,加button,listbox,timer三个组件
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,tlhelp32, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    ListBox1: TListBox;
    Timer1: TTimer;
    procedure Button1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
i:longbool;
ss:string;
had:thandle;
bl:boolean;
tp32:tprocessentry32;
begin
ss:=listbox1.Items.Strings[listbox1.Itemindex];
had:=createtoolhelp32snapshot(th32cs_snapprocess,0);
tp32.dwSize:=sizeof(tp32);
bl:=process32first(had,tp32);
while integer(bl)<>0 do
  begin
      if (tp32.szExeFile)=ss then
      begin
      i:=TerminateProcess(OpenProcess(PROCESS_TERMINATE, BOOL(0),tp32.th32ProcessID), 0);
      if integer(i)<>0 then
      showmessage('关闭'+ss+'成功')
      else
      showmessage('关闭'+ss+'失败');
      break;
      end;
  bl:=process32next(had,tp32);
  end;

end;

 

procedure TForm1.Timer1Timer(Sender: TObject);
 var
had:thandle;
procstruct:TProcessEntry32;
bl:Boolean;
begin
timer1.Interval:=3500;
listbox1.Items.Clear;
had:=createtoolhelp32snapshot(Th32cs_snapprocess,0);
procStruct.dwSize:=sizeof(procstruct);
bl:=process32first(had,procstruct);
while integer(bl)<>0 do
begin
listbox1.Items.add(ProcStruct.szExeFile);
 bl:=process32next(had,ProcStruct);
end;

end;

procedure TForm1.FormCreate(Sender: TObject);
 var
had:thandle;
procstruct:TProcessEntry32;
bl:Boolean;
begin
listbox1.Items.Clear;
had:=createtoolhelp32snapshot(Th32cs_snapprocess,0);
procStruct.dwSize:=sizeof(procstruct);
bl:=process32first(had,procstruct);
while integer(bl)<>0 do
begin
listbox1.Items.add(ProcStruct.szExeFile);
 bl:=process32next(had,ProcStruct);
end;

end;

end.

 

 软件下载:http://www.cnitblog.com/Files/shuyezi122/关闭进程.rar
此程序没有解释,如不明白请阅读我另外两篇文章:
http://www.cnitblog.com/shuyezi122/articles/51301.html

http://www.cnitblog.com/shuyezi122/archive/2008/11/11/51337.html

 

posted on 2008-11-13 18:45 小叶子 阅读(356) 评论(0)  编辑 收藏 引用 所属分类: delphi与电脑知识
只有注册用户登录后才能发表评论。

笔记和文章,可能抄袭,只为学习,请原谅