I have a program written in foxpro (~shudder~) that I've inherited.
The issue is, it has some COM controls in it. When you start 2 copies, the second copy will throw errors. So I thought, this could be cleaned up to bring the active copy to the front allowing only a single instance.
That would be fine, but the program takes a command line parameter allowing it to be run in a different mode. You can only have one copy running in each mode e.g.
1)
"program /bos"
"program /pos" = OK
2)
"program /pos"
"program /pos" = NOT OK
What I'd like is this
"program /pos"
"program /pos" - Bring currently running pos instance to the front.
"program /bos" - start a BOS instance.
"program /bos" - bring the bos instance to the front.
I hope that makes sense. What is an elegant way to determine whether the running instance of program is in pos or bos mode so I can determine which process to bring to the front or whether to start a fresh copy in the requested mode.
I don't necessarily need foxpro code here - although that would be nice. The concept is what I'm after and some hints in regards to the windows API functions to achieve it would also be of help. e.g. can you determine the command line options of a running process?