appo

Search process

Dec 27th, 2013
380
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

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×