• Delphi XE 10.2.3

It is necessary to check the presence (or absence) of the process. For example, there is a Wireshark.exe process and you need to cut down the program if it exists.

I looked through a ton of pages - everything is there for the x86 bit system, and I need a similar function on x64

  • Script for cutting the program is not needed - SlimRG
  • Need boolean function ProccessExists (S: String) - SlimRG

1 answer 1

Found a solution.
And with 64 bits, TLHELP32 works TLHELP32

Here is the code:

 Function IsProcesssRun(processname: string): boolean; var Snapshot: Thandle; proc: TprocessEntry32; begin result := false; Snapshot := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if snapshot = INVALID_HANDLE_VALUE then exit; proc.dwSize := sizeof(TprocessEntry32); if Process32First(snapshot, proc) then repeat if proc.szExeFile = processname then begin result := true; break; end; until not process32next(snapshot, proc); CloseHandle(snapshot); end;