transferring control between 2 programs?
-
In my application I have a button to start another application (a different program altogether). I use the old WinExec which works fine. The problem is that I don't want multiple instances of the other application. (For example the user clicks on the first application and again it gets control and then he clicks on the button again.) What I would like to do is transfer control to that program if it is running and not start and new instance of it. (This would be the equivalent of clicking on its icon on the bar on the bottom of the screen.) Is there a way to do such a thing? Thanks, Ilan
-
In my application I have a button to start another application (a different program altogether). I use the old WinExec which works fine. The problem is that I don't want multiple instances of the other application. (For example the user clicks on the first application and again it gets control and then he clicks on the button again.) What I would like to do is transfer control to that program if it is running and not start and new instance of it. (This would be the equivalent of clicking on its icon on the bar on the bottom of the screen.) Is there a way to do such a thing? Thanks, Ilan
-
In my application I have a button to start another application (a different program altogether). I use the old WinExec which works fine. The problem is that I don't want multiple instances of the other application. (For example the user clicks on the first application and again it gets control and then he clicks on the button again.) What I would like to do is transfer control to that program if it is running and not start and new instance of it. (This would be the equivalent of clicking on its icon on the bar on the bottom of the screen.) Is there a way to do such a thing? Thanks, Ilan
If you have access to the other application's source code, see here.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
In my application I have a button to start another application (a different program altogether). I use the old WinExec which works fine. The problem is that I don't want multiple instances of the other application. (For example the user clicks on the first application and again it gets control and then he clicks on the button again.) What I would like to do is transfer control to that program if it is running and not start and new instance of it. (This would be the equivalent of clicking on its icon on the bar on the bottom of the screen.) Is there a way to do such a thing? Thanks, Ilan
-
maybe: Use ::FindWindow() to check if the other program is running, and get the window handle if it is. Use something like ::SetFocus() or ::SetForegroundWindow() to give the other program control (now that you have its window handle).
DjinnKahn wrote:
Use ::FindWindow()...
...to cause a potential deadlock situation.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
IlanTal wrote:
Is there a way to do such a thing?
There are many ways. See Inter-process communication[^]
-
If you have access to the other application's source code, see here.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
DjinnKahn wrote:
Use ::FindWindow()...
...to cause a potential deadlock situation.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Today in the second program I use a mutex to detect the second instance and kill it. The reply below this one is correct in the sense that I want to give it focus. However I don't know what it means to give focus to a totally different process.
IlanTal wrote:
However I don't know what it means to give focus to a totally different process.
The one and only instance of your "second program" does this with a call to
SetForegroundWindow()
.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
IlanTal wrote:
However I don't know what it means to give focus to a totally different process.
The one and only instance of your "second program" does this with a call to
SetForegroundWindow()
.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne