阿杰 发表于 2009-7-23 19:04:14

【开源】进程名称取进行PID

<p><font face="Verdana">例子:<font face="Verdana">GetPID('explorer.exe')</font></font></p>
<p><font face="Verdana">function GetPID(_GetPID: string): string;<br/>var<br/>h: thandle;<br/>f: boolean;<br/>lppe: tprocessentry32;<br/>begin<br/>h := CreateToolhelp32Snapshot(TH32cs_SnapProcess, 0);<br/>lppe.dwSize := sizeof(lppe);<br/>f := Process32First(h, lppe);<br/>while integer(f) &lt;&gt; 0 do<br/>begin<br/>&nbsp;&nbsp;&nbsp; if lppe.szExeFile = _GetPID then<br/>&nbsp;&nbsp;&nbsp; begin<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Result := (inttostr(lppe.th32ProcessID));<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br/>&nbsp;&nbsp;&nbsp; end;<br/>&nbsp;&nbsp;&nbsp; f := Process32Next(h, lppe);<br/>end;<br/>end;</font></p>
页: [1]
查看完整版本: 【开源】进程名称取进行PID