Naughter Software Logo

CSingleInstance v1.17 An MFC class to implement single instance apps

Welcome to CSingleInstance, an MFC class to make your app into a single instance. Limiting your app to single instance is more tricky in Win32 with the removal of the hPrevInstance parameter from WinMain and the introduction of separate address spaces.

There are numerous examples already out there of making your app single instance, but some published code on the Internet require knowledge of undocumented or heavy duty MFC.

Other methods such as using FindWindow, FindWindowEx are not 100% bullet proof due to the pre-emptive Win32 environment.

 

This class internally uses a memory mapped file (MMF) into which the handle of the main window of your application is stuffed. When a second instance of your app is run, it detects that the memory mapped file exists, gets the window handle of the first instance from the MMF and reactivates the old window.

 

The enclosed zip file contains the CSingleInstance source code and a simple MFC app (without Doc/View)  which demonstrates all the functionality of the class. For further details on how to use the class have a look at the BOOL CMyApp::InitInstance() function and the included documentation

 

Copyright

 

Updates

V1.0 (29 July 1998)

V1.01 (27 March 2000)

V1.02 (28 March 2000)

V1.03 (15 May 2000)

V1.04 (17 May 2000)

V1.05 (1 January 2001)

V1.06 (11 January 2001)

V1.07 (17 June 2001)

V1.08 (21 July 2001)

V1.09 (31 August 2001)

V1.10 (23 March 2002)

1 May 2002

V1.11 (30 October 2002)

V1.12 (6 February 2003)

V1.13 (9 May 2004)

V1.14 (30 May 2005)

V1.15 (7 July 2006)

V1.16 (17 March 2007)

V1.17 (2 February 2008)