daily pastebin goal
76%
SHARE
TWEET

Search process

appo Dec 27th, 2013 331 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function FindProcess(const ExeFile: string): string;
  2. const TH32CS_SNAPPROCESS = $00000002;
  3. var SH: THandle;
  4. TP: TProcessEntry32;
  5. PID: DWORD;
  6. I: Integer;
  7. S: string;
  8. begin Result := '';
  9. if ExeFile = '' then Exit;
  10. SH := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  11. if Integer(SH) < 0 then Exit;
  12. TP.dwSize := SizeOf(TProcessEntry32);
  13. if not Process32First(SH, TP) then Exit;
  14. PID := 0;
  15. for I := 0 to 999 do
  16. begin
  17. S := UpperCase(TP.szExeFile);
  18. if SameText(ExeFile, S) then
  19. begin
  20. PID := TP.th32ProcessID;
  21. Break;
  22. end;
  23. if not Process32Next(SH, TP) then Break;
  24. end;
  25. if PID = 0 then Exit;
  26. Result := S;
  27. end;
  28.  
  29. // Coded by Appo //
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top