Please enable JavaScript to view this site.

ESL Documentation

Navigation: » No topics above this level «

Q4 How do I prevent more than one copy of an ESL application running on a machine?

Scroll Prev Top Next More

The following sample program shows how to prevent multiple copies of itself from being run on the same machine via DDE. The program first checks to see if a previous instance is already registered as a DDE server. If one is, the current program terminates itself. If one is not, the current program registers itself as a DDE server for future reference.

CodeSamples_Q04

You must not attempt to Initiate a DDE conversation with any instance of the ESL application otherwise there will be DDE messages generated, which will need to be managed. The DDEPollTopics function handles all the DDE messages. If your ESL application can be closed by means other than closing the Primary Window, you must ensure the DDEUnRegisterServer routine is called prior to the application exiting.

The above technique is also useful for other circumstances where an ESL application needs to know if another instance of itself is already running.