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.
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.
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.
I also tried EnumWindows from ABC Free. But executing the code seemed to freeze the 3 procedure-app.
I do recall @anon77170705 made reference in this post to Process32First and Process32Next
How to access the Win32 library functions is still a new area for me.
Yiippee!! your example in “procrun.zip” worked first time. Simple and easy to implement.
Seems WindowExtenderClass.IsInstanceRunning just doesn’t work in most cases, If a requested process is actually running, _Process32First or _Process32Next finds it successfully but a subsequent comparision “IF th32sessionsID = currentSID” usually fails because currentSID has default value 0, and th32sessionsID <> 0.