views:

36

answers:

2

What are some options for keeping a persistent reference to two applications even if one crashes so that when re-opening the first one, it can get a reference to the second one and call methods on it.

The situation is as follows:

  • App1 (a web browser plugin) instantiates App2 via a object reference in an HTML page and gets a reference to it so that it can make API calls to App2.

  • App1 crashes but App2 stays open.

  • When App1 re-opens, it needs to get a reference to App2 (still running) so that it can continue to make API calls.

This is all done running as admin on the machine. What is the best way for App1 to get a reference to the still running App2 when it re-opens after crashing?

+1  A: 

There are many different options for IPC that would work.

If you're trying to make API calls from App1 to App2, you're already using some form of IPC in there. I'd just use something like named pipes that allow usage from any process. If App2 is a pipe server, App1 can connect to it, and if it crashes, the new App1 can just connect to it as a client again.

Reed Copsey
A: 

You could try using EnumProcesses to find the running App.

There is some example code at http://msdn.microsoft.com/en-us/library/ms682623(VS.85).aspx.

Adam Pierce