Olaf Doschke
Programmer
We all know and use methods to prevent double starts. I maintain an application that already implmented the usual FindWindow/SetForeGroundWindows method.
A customer's suspicion is, this still doesn't work. I found a possible flaw in the logic, and while I am at rewriting this I remembered WMI queries fro win32_process can also show you whether a process of an exe runs in a separate Windows session.
So my new code works on that basis and I end up with a ProcessIds instead of Hwnd. And I found an easy way to activate a process by that instead of SetForeGroundWindow via this:
My first tests are all successful, but here's the thing I can't explain: The result value of the AppActivate() call should tell, whether the activation succeeded. But mostly it returns .F., even when the app activation does work.
OK, that's lamenting over a detail, which isn't really a problem, as long as it works it's totally sufficient, but I ask myself: "how reliable is it?"
Does anybody already use WScript.Shell AppActivate? Or are you willing to experiment with it and see whether it works reliable for you, too?
You don't even need any more code to find out a process ID, if you experiment with several Foxpro sessions started one can activate the other once you know the _vfp.processid of the session you want to activate. I'd also be interested in whether this works on WinXP,7 and 8, too.
Bye, Olaf.
Olaf Doschke Software Engineering
A customer's suspicion is, this still doesn't work. I found a possible flaw in the logic, and while I am at rewriting this I remembered WMI queries fro win32_process can also show you whether a process of an exe runs in a separate Windows session.
So my new code works on that basis and I end up with a ProcessIds instead of Hwnd. And I found an easy way to activate a process by that instead of SetForeGroundWindow via this:
Code:
oWSSH = CreateObject("WScript.Shell")
oWSSH.AppActivate(Processid)
My first tests are all successful, but here's the thing I can't explain: The result value of the AppActivate() call should tell, whether the activation succeeded. But mostly it returns .F., even when the app activation does work.
OK, that's lamenting over a detail, which isn't really a problem, as long as it works it's totally sufficient, but I ask myself: "how reliable is it?"
Does anybody already use WScript.Shell AppActivate? Or are you willing to experiment with it and see whether it works reliable for you, too?
You don't even need any more code to find out a process ID, if you experiment with several Foxpro sessions started one can activate the other once you know the _vfp.processid of the session you want to activate. I'd also be interested in whether this works on WinXP,7 and 8, too.
Bye, Olaf.
Olaf Doschke Software Engineering