Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 2.2

COLUMN

Allow only one application instance to run at the same time.

About using the Windows API to create a mutex object.

Issue: 2.2 (October/November 2003)
Author: Christian Schmitz
Author Bio: Christian Schmitz is the creator of the Monkeybread Software REALbasic Plugins.
Article Description: No description available.
Article Length (in bytes): 10,746
Starting Page Number: 42
Article Number: 2220
Resource File(s):

Download Icon 2220.zip Updated: 2013-03-11 19:07:57

Related Web Link(s):

http://msdn.microsoft.com/library/en-us/dllproc/base/releasemutex.asp

Excerpt of article text...

What do we want?

If you double click an application file in Windows, you will notice that the application is launched even if it is already running. So you can launch several application instances from one application file in Windows.

For many applications this is not what developers want. So they do some magic stuff to avoid the second application instance. You can do this several ways:

1. You can check the temporary folder to see if there is a special file there. If the file exists you have a second copy running, else you create the file. As your application will fail to delete the file when it crashes, we don't use this way to solve our problem.

2. If you do networking in your application via sockets, you can handle the case of a special string being received from an incoming socket by responding with some other string. When your application is started, have it open a connection to "127.0.0.1" (localhost). If the connection is accepted and the other side answers with the correct string, you know your application is already running.

...End of Excerpt. Please purchase the magazine to read the full article.