如何获取windouws进程句柄(不要findwindow)(50分)

  • 主题发起人 主题发起人 wdy801229
  • 开始时间 开始时间
W

wdy801229

Unregistered / Unconfirmed
GUEST, unregistred user!
如何获取windouws进程句柄(不要findwindow)
 
得到当前进程句柄:GetCurrentProcess()<br>&nbsp;<br>
 
Function &nbsp;GetProcessList(Ts_Exe,Ts_EMS,Ts_PID:Tstrings):boolean;<br>var Pn: TProcesseNtry32; sHandle: THandle;<br>&nbsp; &nbsp; &nbsp; &nbsp; Found: Boolean;<br>begin<br>&nbsp; &nbsp; &nbsp; &nbsp; Ts_Exe.Clear;Ts_EMS.Clear;<br>&nbsp; &nbsp; &nbsp; &nbsp; Ts_PID.Clear;<br>&nbsp; &nbsp; &nbsp; &nbsp; sHandle := CreateToolHelp32SnapShot(TH32CS_SNAPALL, 0);<br>&nbsp; &nbsp; &nbsp; &nbsp; Found := Process32First(sHandle, Pn);<br>&nbsp; &nbsp; &nbsp; &nbsp; While Found do<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Ts_Exe.Add(ExtractFileName(Pn.szExeFile));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Ts_EMS.Add(ExtractFilePath(Pn.szExeFile));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TS_PID.Add(IntToStr(Pn.th32ProcessID));<br>&nbsp; &nbsp; &nbsp; &nbsp; Found := Process32Next(sHandle, Pn);<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; Result:= Found;<br>end;
 
to jfyes :能否给点注释,吾乃菜鸟<br>多谢!
 
在uses 加入TlHelp32单元,“Pn”是TProcesseNtry32 record记录类型;
 
多人接受答案了。
 
给错了[:(]
 
楼主你那么公平呀?
 
后退
顶部