杀死窗口进程:

来源:互联网 发布:学数据库用什么软件 编辑:程序博客网 时间:2024/05/21 22:42

杀死窗口进程:
procedure TForm1.Button5Click(Sender: TObject);
var
H:THandle;
P:DWORD;
s:string;
killed:boolean;
begin
s := ListBox1.Items[ListBox1.ItemIndex];
H:=FindWindow(nil,pchar(s));
if H<>0 then
begin
   GetWindowThreadProcessId(H,@P);
   if P<>0 then
     killed:=TerminateProcess(OpenProcess(PROCESS_TERMINATE,False,P),$FFFFFFFF);
   if not killed then
     messagebox(self.handle,pchar(s+'无法杀死!'),'提示',MB_OK or MB_ICONWARNING)
   else
     ListBox1.Items.Delete(ListBox1.ItemIndex);
end;

end;

原创粉丝点击