Jump to content
Excelsior Forums
Sign in to follow this  
Graham

Single instances of applications

Recommended Posts

Hi,

Is there any way to make sure that only one copy of the same application is running at the same time - I know there are a couple of native Java ways of doing it (sockets and file locking) but there are potential problems with both of them. Is there any way Jet can help?

? Graham

Share this post


Link to post
Share on other sites

Hi,

the JET Runtime does not provide such functionality out-of-the-box so you have to write a Java native method for that.

I know there are a couple of native Java ways of doing it (sockets and file locking)

There is a more simpler trick: use a named mutex (semaphore) shared between processes. In Windows programming, it's a recommended way to implement the "single instance" check.

Within the native method, create a mutex with a unique name, e.g. it can have a name specific to a particular version of your app.

If the mutex already exists, the Win API returns code

? ?ERROR_ALREADY_EXISTS

that you can use to distinguish between the first and second instances of the application.

For more information, consult MSDN at

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcemain4/html/cerefcreatemutex.asp

Take care,

ZZ Top

B)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×