如何查找windows 任务管理器里面是否有某一个进程,有的话结束 windows 任务管理器里面的这一个进程,例如要结束windows 任务管理器里的photoshop.exe这个进程,应该如何做? 要求要在win98和win2000以上系统都能正常使用的。
解决方案 »
- delphi 中提取 webbrowser鼠标单击的超链接的文字内容
- 送分
- tstringlist的用法,小菜.....帮解惑....
- 急:怎么想表单提交复选框的值
- 高手请进。。。。
- 面向对象编程,关于自定义类、对象的问题?
- delphi ADOQuery if语句如何改正,目前显示“list index out of bounds(2)"
- delphi7无法显示控件的hint
- PCOM控件中的sio_ioctl(),参数如何动态设置?特别是第三个参数,
- 请问Winapi函数的主要特点及相关的介绍,它与DLL函数及DELPHI中的RTL系统函数的区别?在DELPHI中使用时好像不用作SPECIAL STATEMENT吧?谢谢!
- 为什么应届生那么难找工作?》?散分
- 界面怎么根据radiobutton选择而变化?()
Form1: TForm1;
Wnd: HWND;
implementation{$R *.DFM}Function EnumWindowsProc (Wnd: HWND; lb: TListbox): BOOL; stdcall;
var
caption: Array [0..128] of Char;
begin
Result := True;
if { skip invisible windows }
IsWindowVisible(Wnd) and
{ only process truly top-level windows. GetWindowLong must be used, not
GetParent }
((GetWindowLong(Wnd, GWL_HWNDPARENT) = 0) or
(HWND(GetWindowLong(Wnd, GWL_HWNDPARENT)) = GetDesktopWindow)) and
{ skip WS_EX_TOOLWINDOW windows }
((GetWindowLong(Wnd, GWL_EXSTYLE) and WS_EX_TOOLWINDOW) = 0)
then begin
SendMessage( Wnd, WM_GETTEXT, Sizeof( caption ), integer(@caption));
lb.Items.AddObject( caption, TObject( Wnd ));
end;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
listbox1.clear;
EnumWindows( @EnumWindowsProc, integer( listbox1 ));
end;procedure TForm1.ListBox1Click(Sender: TObject);
var
theClassname: Array [0..128] of Char; tid, pid: DWORD;
intExitCode:DWORD;
begin
With Sender As TListbox Do Begin
If ItemIndex >= 0 Then Begin
Wnd:= HWND(Items.Objects[ itemindex ]);
If Wnd <> 0 Then Begin
Windows.GetClassname( Wnd, theClassname, Sizeof( classname ));
tid := GetWindowThreadProcessID( Wnd, @pid );
label1.caption :=
Format(
'HWND: %8.8x'#13#10+
'Class: %s'#13#10+
'Process ID: %8.8x'#13#10+
'Thread ID: %8.8x',
[Wnd, theClassname, pid, tid] );
End;
End;
End;
end;
进程列表
type
TProcessInfo = Record
ExeFile : String;
ProcessID : DWORD;
end;
pProcessInfo = ^TProcessInfo;
var p : pProcessInfo;
ContinueLoop:BOOL;
FSnapshotHandle:THandle;
FProcessEntry32:TProcessEntry32;
begin
memo1.Clear;
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;
memo1.lines.Add(p.ExeFile+' : '+inttostr(p.ProcessID));
ContinueLoop:=Process32Next(FSnapshotHandle,FProcessEntry32);
end;
end;