Is an EXE or Process Running?

My Clarion emailtimer app relies on another app called “scanner.exe” to be running. It’s a vb.net application, and I have set it so that only one instance is running. I could just try executing “scanner.exe” on a regular basis, but that’s a horrible solution, and in other examples I would end up with hundreds of copies of the same app running until windows crashes.

In vb.net there is a function called GetProcessesByName(“scanner.exe”)
Member of System.Diagnostics.Process
In the windows32 PSAPI there are functions to enumerate the running processes. I have looked at the winapi by @Mike_Duglas but can’t find anything that matches.

Any suggestions?

winapi - How can I get a process handle by its name in C++? - Stack Overflow

You can use TToolHelp class from my winapi, all needed methods are in there.

1 Like

In LibSrc \ WinExt.Clw / .INC you’ll find:

WindowExtenderClass.IsInstanceRunning PROCEDURE(<STRING processExeName>)

It may be all you need, but it has the code to call Process32First() and Process32Next() that should help you write your own.

See Also:

1 Like

I’m missing something really obvious here: what do I need to do to get the IsInstanceRunning method to work? If I just add this code to the main frame’s timer event I get errors complaining about no matching prototype. So clearly I haven’t included missing bits.

  !// Timer event
  if IsInstanceRunning('scanner.exe') then
      message('scanner.exe')
  end

I have searched in vain through the Clarion documentation and PDFs and found a cryptic reference to the WindowExtender class, but nothing further.

I have included the line INCLUDE('winext.inc'),ONCE in the “After Global INCLUDEs” global embed, but I’m not sure if that’s correct, and I don’t know whether to include winext.clw anywhere.

I’m missing something basic.

IsInstanceRunning is a method of a class, not a standalone procedure.
You need to declare an instance of WindowExtenderClass and then call the IsInstanceRunning for that class.