How to run at most one instance at a time?

How can i modify the original MDI template so that at most one instance can be run simutaneously?
p0yang01Asked:
Who is Participating?
 
prasanthConnect With a Mentor Commented:
In Win32, there are three ways of checking for a previous instance:

· Creating and testing for the existence of a named mutex.
· Creating a unique named pipe
· Calling FindWindow with the window class and name.

Which ever method you choose, it should be done in InitInstance of your application.

The easiest is calling FindWindow in InitInstance and if a window is found, setting focus to it and returning FALSE from InitInstance.
0
 
danny_pavCommented:
create a shared segment and that will have data from all instances of the app.  Use InterLockedIncrement/Dec to modify counters in the shared segment
0
All Courses

From novice to tech pro — start learning today.