CSingleInstance

1.24

Limit your applications to a single instance by turning to this C++ class that can be easily implemented and features an example

CSingleInstance is a C++ class that was designed to help advanced computer users such as programmers or software developers make their applications into single instances, which can be a tricky process since lately some native components have been removed while others have been recently introduced.
Win32 can make it difficult to create single instances out of target applications since the hPrevInstance parameter has been removed from WinMain while separate address spaces have been introduced.
Although the Internet has many methods that users can follow in order to limit their applications to single instances, some of the codes that are published online require advanced understanding and operating of MFC, which is short for Microsoft Foundation Classes.
Other similar methods that make use of FindWindowEx or FindWindow are not guaranteed to yield the expected effect due to the Win32 environment. Therefore, CSingleInstance can mean staying on the safe side whenever trying to create single instances out of programs.
This C++ class encompasses an MMF (memory mapped file) that contains the handle of the main window of the target application. Whenever a second instance of the target application is being executed, the existance of the MMF is detected, the window handle is retrieved and the old window is reactivated.