挂起一个进程中的线程

ba21 2013-01-29 06:52:15
如题,以下代码可以取ID但不知何挂起:
procedure TForm1.Button6Click(Sender: TObject);
var lppe:Tprocessentry32;
hh,tt:Thandle;
tppe:TThreadEntry32;
PId:Dword;
hthread:Dword;
begin
hh:=createtoolhelp32snapshot(TH32CS_SNAPPROCESS,0);
lppe.dwsize:=sizeof(lppe);
tppe.dwsize:=sizeof(tppe);
if process32first(hh,lppe) then
repeat
pid:=lppe.th32ProcessID;
// listbox1.items.add(format('<%x>%s',[pid,extractfilename(lppe.szExeFile)]));
if extractfilename(lppe.szExeFile)='c.exe' then
begin
tt:=createtoolhelp32snapshot(TH32CS_SNAPTHREAD,0);
if thread32first(tt,tppe) then
repeat
if tppe.th32OwnerProcessID=pid then
// hthread:=OpenThread($2, FALSE, tppe.th32ThreadID);
// SuspendThread(hThread);

listbox1.items.add(format(' theadid:<%x>',[tppe.th32ThreadID]));

until not thread32next(tt,tppe);
closehandle(tt);
end;
until not process32next(hh,lppe);
CloseHandle(hh);
edit1.text:=inttostr(listbox1.items.count);

end;
...全文
909 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
ba21 2013-02-05
  • 打赏
  • 举报
回复
「已注销」 2013-01-30
  • 打赏
  • 举报
回复
MSDN搜索 SuspendThread

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧