/***********************************************************************/ /* Copyright (C) 2002 Definitive Solutions, Inc. All Rights Reserved. */ /* THIS COMPUTER PROGRAM IS PROPRIETARY AND CONFIDENTIAL TO DEFINITIVE */ /* SOLUTIONS, INC. AND ITS LICENSORS AND CONTAINS TRADE SECRETS OF */ /* DEFINITIVE SOLUTIONS, INC. THAT ARE PROVIDED PURSUANT TO A WRITTEN */ /* AGREEMENT CONTAINING RESTRICTIONS ON USE AND DISCLOSURE. ANY USE, */ /* REPRODUCTION, OR TRANSFER EXCEPT AS PROVIDED IN SUCH AGREEMENT */ /* IS STRICTLY PROHIBITED. */ /***********************************************************************/ #ifndef MYSINGLEINSTANCEH_3F2BB082_2AE3_11d6_8ACA_00B0D0529ED2_INCLUDED_ #define MYSINGLEINSTANCEH_3F2BB082_2AE3_11d6_8ACA_00B0D0529ED2_INCLUDED_ #pragma once ///////////////////////////////////////////////////////////////////////////// // How to add this class to your application. // // Add MySingleInstance.cpp and MySingleInstance.h to your project in the usual // folders. // // To keep the mutex alive the whole time you app is running, you must add a // member variable to your app class: // // MySingleInstance m_singleInstance; // Mutex to allow only one instance // // of this app to run at a time. // // Add this near near the top of your app's InitInstance(): /* // Check if an instance of our application is already running. if (FAILED(m_singleInstance.Create(IDR_MAINFRAME))) { return FALSE; } */ // Add this to your CMainFrame's PreCreateWindow() method: /* // Added for MySingleInstance. Set this application's CMainFrame window's // class name to a unique value from the MySingleInstance object. CYourApp* pApp = dynamic_cast (AfxGetApp()); ASSERT_VALID(pApp); if (pApp) { cs.lpszClass = pApp->m_singleInstance.GetClassName(); } */ ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // MySingleInstance class MySingleInstance { // Construction. public: MySingleInstance(); virtual ~MySingleInstance(); // Operations. public: HRESULT Create(UINT nID); CString GetClassName() const; // Data. private: HANDLE m_hMutex; // Mutex that is locked when this app opens. // Needs to be at class scope so it doesn't // unlock at the end of a function. CString m_sClassName; // Unique name to all us to activate the // running instance. }; #endif // MYSINGLEINSTANCEH_3F2BB082_2AE3_11d6_8ACA_00B0D0529ED2_INCLUDED_