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?
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.
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
All Courses

From novice to tech pro — start learning today.