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

An MFC extension library to enable DLL plug-in technology for your application using MESSAGE_MAPs

Rate me:
Please Sign up or sign in to vote.
4.85/5 (47 votes)
8 Jun 2004CPOL17 min read 576.8K   8.6K   238  
A plug-in architecture which allows you to write plug-in DLLs for your application and extend/modify its functionality.
//
// 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()
//          RIA / 2004      1. Added command line passing to other instance
//
// Copyright (c) 1998 - 2000 by PJ Naughter.  
// All rights reserved.
//
#pragma once

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

// message sent when sending command line to other running instance
#define	WM_COMMANDLINE		_T("UWM_COMMANDLINE")

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

//General functions
	BOOL	        TrackFirstInstanceRunning();
	BOOL	        PreviousInstanceRunning();
	HWND	        ActivatePreviousInstance(CString command_line); 
	CString	        GetCommandLine();
	void	        SetWindowHandle(HWND hwnd);

protected:
	virtual HWND    GetWindowToTrack();
	void	        ReleaseLock();
	LPCTSTR	        MakeMMFFilename();
	CMutex	        m_instanceDataMutex;
	CMutex	        m_executeMutex;
	CSingleLock*    m_pExecuteLock;
    CString         m_productName;
};

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Sirius Analytical Instruments
United Kingdom United Kingdom
A research and development programmer working for a pharmaceutical instrument company for the past 17 years.

I am one of those lucky people who enjoys his work and spends more time than he should either doing work or reseaching new stuff. I can also be found on playing DDO on the Cannith server (Send a tell to "Maetrim" who is my current main)

I am also a keep fit fanatic, doing cross country running and am seriously into [url]http://www.ryushinkan.co.uk/[/url] Karate at this time of my life, training from 4-6 times a week and recently achieved my 1st Dan after 6 years.

Comments and Discussions