Click here to Skip to main content
15,884,075 members
Articles / Desktop Programming / MFC

CSingleInstance - Single Instance Apps

Rate me:
Please Sign up or sign in to vote.
4.98/5 (15 votes)
3 Mar 2000 270.7K   2.3K   69  
An MFC class to implement single instance apps.
/*
Module : SINSTANCE.H
Purpose: Defines the interface for an MFC wrapper class to do instance checking
Created: PJN / 29-07-1998
History: PJN / 25-03-2000 Neville Franks made the following changes. Contact nevf@getsoft.com, www.getsoft.com
                          1. Changed #pragma error to #pragma message. Former wouldn't compile under VC6
                          2. Replaced above #pragma with #include
                          3. Added TrackFirstInstanceRunning(), MakeMMFFilename()

Copyright (c) 1998 - 2000 by PJ Naughter.  
All rights reserved.
*/

#ifndef __SINSTANCE_H__
#define __SINSTANCE_H__


#ifndef __AFXMT_H__
#include "afxmt.h"
#endif

class CInstanceChecker : public CObject
{
public:
//Constructors / Destructors
  CInstanceChecker();
  ~CInstanceChecker();

//General functions
  BOOL TrackFirstInstanceRunning();
  BOOL PreviousInstanceRunning();
  HWND ActivatePreviousInstance(); 

protected:
  CString MakeMMFFilename();
	CMutex m_instanceDataMutex;
	HANDLE m_hPrevInstance;
};


#endif //__SINSTANCE_H__

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions