【开源】进程名称取进行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) <> 0 do<br/>begin<br/> if lppe.szExeFile = _GetPID then<br/> begin<br/> Result := (inttostr(lppe.th32ProcessID));<br/> break;<br/> end;<br/> f := Process32Next(h, lppe);<br/>end;<br/>end;</font></p>
页:
[1]