Click here to Skip to main content
12,404,478 members (73,332 online)
Click here to Skip to main content

Stats

65.2K views
424 downloads
40 bookmarked
Posted

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

, 17 Apr 2006 CPOL
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)

Share

About the Author

Werner Willemsens
Team Leader
Belgium Belgium
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160721.1 | Last Updated 17 Apr 2006
Article Copyright 2006 by Werner Willemsens
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid