LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I tell if an executable is already running?

Solved!
Go to solution

I'm writing a rather large LabWindows/CVI program, and occasionally will triple-click on the desktop icon, starting two copies of it. Is there some way to tell if a program is already running, so that the second copy can shut itself off?

0 Kudos
Message 1 of 6
(3,404 Views)
Solution
Accepted by pblase

Look at CheckForDuplicateAppInstance () command: the help page shows also a short programming example.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 6
(3,400 Views)

Or if you want to do it another way create a named mutex that the application grabs when it starts, that way if it can't grab the named mutex you know that another instance of the application is already running.

 

Message 3 of 6
(3,375 Views)

Ok, thanks much. I thought I remembered something being in there somewhere.

0 Kudos
Message 4 of 6
(3,367 Views)
> Or if you want to do it another way create a named mutex that the
> application grabs when it starts, that way if it can't grab the named
> mutex you know that another instance of the application is already
> running.

Yet another way is to open a resource exclusively.
For instance with:
open(Filename, O_CREAT | O_EXLC | O_TEMPORARY)
The 2nd one will fail the call
--
Guillaume Dargaud
http://www.gdargaud.net/
Message 5 of 6
(3,343 Views)

Speaking of using a resource, I used a named pipe to solve this problem in grad school once.  Prof thought it was weird but he couldn't deny that it does work Smiley Wink

Message 6 of 6
(3,342 Views)