Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2007-10

Cross-platform single instance

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Felipe Monteiro de Carvalho

Hello,

I was looking into a way to detect if an instance of my application is running. Is there a cross-platform solution on rtl or fcl?

It seams that semaphores would be a good solution. I took a look at pthreads and PSemaphore but that is only an alias for unix specific semaphores.

If there is no current solution for this problem, may I implement pthreads for Windows? Or maybe a new unit? I remember using Mutex Windows APIs to do what I need in the past. There are probably Semaphore functions that could be used to provide a uniform interface across the supported platforms.

thanks,

Felipe Monteiro de Carvalho
Vincent Snijders
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 15 lines
Hello, I was looking into a way to detect if an instance of my application is running. Is there a cross-platform solution on rtl or fcl? It seams that semaphores would be a good solution. I took a look at pthreads and PSemaphore but that is only an alias for unix specific semaphores. If there is no current solution for this problem, may I implement pthreads for Windows? Or maybe a new unit? I remember using Mutex Windows APIs to do what I need in the past. There are probably Semaphore functions that could be used to provide a uniform interface across the supported platforms.

Have you considered UniqueInstance?
http://wiki.lazarus.freepascal.org/UniqueInstance

Vincent

Luiz Americo Pereira Camara
to Vincent Snijders
Vincent Snijders wrote 20 lines
Felipe Monteiro de Carvalho schreef: > Hello, > > I was looking into a way to detect if an instance of my application is > running. Is there a cross-platform solution on rtl or fcl? > > It seams that semaphores would be a good solution. I took a look at > pthreads and PSemaphore but that is only an alias for unix specific > semaphores. > > If there is no current solution for this problem, may I implement > pthreads for Windows? Or maybe a new unit? I remember using Mutex > Windows APIs to do what I need in the past. There are probably > Semaphore functions that could be used to provide a uniform interface > across the supported platforms. > Have you considered UniqueInstance? http://wiki.lazarus.freepascal.org/UniqueInstance

The updated version can be found at
https://svn.bountysource.com/luipack/trunk/uniqueinstance

Requires fpc 220.

Can work both in Lazarus app or console app.

It works both in Linux (Tested Ubuntu Feisty) and Windows (Tested Xp SP2).

I will prepare a new release in ASAP.

Luiz

Luiz Americo Pereira Camara
to Luiz Americo Pereira Camara: The updated version can be found at https://svn.bountysource.com/luipack/trunk/uniqueinsta…
Luiz Americo Pereira Camara wrote 6 lines
Vincent Snijders wrote: > Have you considered UniqueInstance? > http://wiki.lazarus.freepascal.org/UniqueInstance > The updated version can be found at https://svn.bountysource.com/luipack/trunk/uniqueinstance

I released a new version. Look in
http://wiki.lazarus.freepascal.org/UniqueInstance to info how to grab it

Luiz