无
无限风
Unregistered / Unconfirmed
GUEST, unregistred user!
怎样关闭在ListView中选定的进程
程序:
type
TProcessInfo = Record
ExeFile : String;
ProcessID : DWORD;
end;
pProcessInfo = ^TProcessInfo;
type
; TForm1 = class(TForm)
; ; Button1: TButton;
; ; ListView1: TListView;
; ;
; ; procedure FormCreate(Sender: TObject);
; ; procedure Button1Click(Sender: TObject);
; private
; ; { Private declarations }
; public
; ; { Public declarations }
; end;
var
; Form1: TForm1;
; processlist:array of word ;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
var p : pProcessInfo;
ContinueLoop:BOOL;
; ;ListItem: TListItem;
FSnapshotHandle:THandle;
FProcessEntry32:TProcessEntry32;
i:integer;
begin
;FSnapshotHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
;FProcessEntry32.dwSize:=Sizeof(FProcessEntry32);
;ContinueLoop:=Process32First(FSnapshotHandle,FProcessEntry32);
;while integer(ContinueLoop)<>0 do
; begin
; ;New(p);
; ; ;p.ExeFile := FProcessEntry32.szExeFile;
; ; ;p.ProcessID := FProcessEntry32.th32ProcessID;
; ; ;ListItem := listview1.Items.Add;
; ; ;ListItem.Caption := Format('%d',[p.ProcessID]);
; ; ;ListItem.SubItems.Add(Format('%s',[p.ExeFile]));
ContinueLoop:=Process32Next(FSnapshotHandle,FProcessEntry32);
;end;
end;
procedure TForm1.Button1Click(Sender: TObject);//关闭进程
var Exehandle:thandle;
; ; ;s,str:string;
begin
;??? ; ; ;//s:=listview1.Items[listbox1.ItemIndex];
; ; ; ; ;//ExeHandle:=Findwindow(nil,pchar(s));
; ; ; ; //if ;ExeHandle<>0 then
; ; ; ;// PostMessage(ExeHandle,WM_CLOSE,0,0);
end;
end.
程序:
type
TProcessInfo = Record
ExeFile : String;
ProcessID : DWORD;
end;
pProcessInfo = ^TProcessInfo;
type
; TForm1 = class(TForm)
; ; Button1: TButton;
; ; ListView1: TListView;
; ;
; ; procedure FormCreate(Sender: TObject);
; ; procedure Button1Click(Sender: TObject);
; private
; ; { Private declarations }
; public
; ; { Public declarations }
; end;
var
; Form1: TForm1;
; processlist:array of word ;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
var p : pProcessInfo;
ContinueLoop:BOOL;
; ;ListItem: TListItem;
FSnapshotHandle:THandle;
FProcessEntry32:TProcessEntry32;
i:integer;
begin
;FSnapshotHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
;FProcessEntry32.dwSize:=Sizeof(FProcessEntry32);
;ContinueLoop:=Process32First(FSnapshotHandle,FProcessEntry32);
;while integer(ContinueLoop)<>0 do
; begin
; ;New(p);
; ; ;p.ExeFile := FProcessEntry32.szExeFile;
; ; ;p.ProcessID := FProcessEntry32.th32ProcessID;
; ; ;ListItem := listview1.Items.Add;
; ; ;ListItem.Caption := Format('%d',[p.ProcessID]);
; ; ;ListItem.SubItems.Add(Format('%s',[p.ExeFile]));
ContinueLoop:=Process32Next(FSnapshotHandle,FProcessEntry32);
;end;
end;
procedure TForm1.Button1Click(Sender: TObject);//关闭进程
var Exehandle:thandle;
; ; ;s,str:string;
begin
;??? ; ; ;//s:=listview1.Items[listbox1.ItemIndex];
; ; ; ; ;//ExeHandle:=Findwindow(nil,pchar(s));
; ; ; ; //if ;ExeHandle<>0 then
; ; ; ;// PostMessage(ExeHandle,WM_CLOSE,0,0);
end;
end.