Click here to Skip to main content
15,896,348 members
Articles / Mobile Apps / Windows Mobile

Bringing DCOM remoting functionality to Windows CE and .NET CF2.0

Rate me:
Please Sign up or sign in to vote.
4.93/5 (11 votes)
17 Apr 2006CPOL14 min read 97.3K   513   40  
This article shows how to use DCOM on Windows CE 5.0. We will add full DCOM rich error information, and implement a DCOM interface between a Windows XP .NET 2.0 client and Windows CE DCOM server. With this code, it is possible to code .NET remoting alike functionality through DCOM interop.
////////////////////////////////////////////////////////////////////
//
//  Copyright (C) 2006 Werner Willemsens
//
////////////////////////////////////////////////////////////////////

// Gate.h : Declaration of the CGate

#pragma once
#ifdef STANDARDSHELL_UI_MODEL
#include "resource.h"
#endif
#ifdef POCKETPC2003_UI_MODEL
#include "resourceppc.h"
#endif
#ifdef SMARTPHONE2003_UI_MODEL
#include "resourcesp.h"
#endif
#ifdef AYGSHELL_UI_MODEL
#include "resourceayg.h"
#endif

#include "StarGatePS.h"
#include "_IGateEvents_CP.h"

#define MIN_CHEVRON_COUNT		7	// 7, only our galaxy
#define MAX_CHEVRON_COUNT		9	// 9, we might even dial Atlantis :-)
#define MAX_CHEVRON_SYMBOL		39

// CGate
class ATL_NO_VTABLE CGate :
	public CComObjectRootEx<CComMultiThreadModel>,
	public CComCoClass<CGate, &CLSID_Gate>,
	public ISupportErrorInfo,
	public IConnectionPointContainerImpl<CGate>,
	public CProxy_IGateEvents<CGate>,
	public IDispatchImpl<IGate, &IID_IGate, &LIBID_StarGateLib, /*wMajor =*/ 1, /*wMinor =*/ 0>
{
public:
	CGate();
	~CGate();

#ifdef _CE_DCOM
DECLARE_REGISTRY_RESOURCEID(IDR_GATEDCOM)
#endif

BEGIN_COM_MAP(CGate)
	COM_INTERFACE_ENTRY(IGate)
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
	COM_INTERFACE_ENTRY(IConnectionPointContainer)
END_COM_MAP()

BEGIN_CONNECTION_POINT_MAP(CGate)
	CONNECTION_POINT_ENTRY(__uuidof(_IGateEvents))
END_CONNECTION_POINT_MAP()

// ISupportsErrorInfo
	STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);

	DECLARE_NOT_AGGREGATABLE(CGate)
//	In case you only have 1 working StarGate :-)
//	DECLARE_CLASSFACTORY_SINGLETON(CGate)
	DECLARE_PROTECT_FINAL_CONSTRUCT()

	HRESULT FinalConstruct()
	{
		return S_OK;
	}

	void FinalRelease()
	{
	}

public:
	STDMETHOD(DialGate)(LONG Chevron);
	STDMETHOD(CloseGate)();
	STDMETHOD(get_IsOpen)(VARIANT_BOOL* pVal);

protected:
	// Handles Opened() events
	void ProcessOpened(VARIANT *aValue);

protected:
	long				m_ChevronEntered[MAX_CHEVRON_COUNT];
	long				m_ChevronCount;
	CRITICAL_SECTION	m_ChevronProtect;
};

OBJECT_ENTRY_AUTO(__uuidof(Gate), CGate)

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
Team Leader
Belgium Belgium
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions