Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

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

, 17 Apr 2006
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) 2005 Werner Willemsens
//  
///////////////////////////////////////////////////////////////////////

#ifndef _HOOK_H
#define _HOOK_H

#include <windows.h>
#include <oaidl.h>
#include <comutil.h>
#include <comdef.h>

static const GUID IID_IMarshalRichError = 
	{ 0x0000031C, 0x0000, 0x0000, { 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 } };
static const GUID IID_IUnmarshalRichError = 
	{ 0x0000031B, 0x0000, 0x0000, { 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 } };

class Hook : public IChannelHook
{
public:
	STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
	STDMETHODIMP_(ULONG) AddRef(void);
	STDMETHODIMP_(ULONG) Release(void);

    STDMETHODIMP_(void) ClientGetSize(REFGUID uExtent, REFIID riid, ULONG *pDataSize);
    STDMETHODIMP_(void) ClientFillBuffer(REFGUID uExtent, REFIID riid, ULONG *pDataSize, void *pDataBuffer);
    STDMETHODIMP_(void) ClientNotify(REFGUID uExtent, REFIID riid, ULONG cbDataSize, void *pDataBuffer, DWORD lDataRep, HRESULT hrFault);

    STDMETHODIMP_(void) ServerNotify(REFGUID uExtent, REFIID riid, ULONG cbDataSize, void *pDataBuffer, DWORD lDataRep);
    STDMETHODIMP_(void) ServerGetSize(REFGUID uExtent, REFIID riid, HRESULT hrFault, ULONG *pDataSize); 
    STDMETHODIMP_(void) ServerFillBuffer(REFGUID uExtent, REFIID riid, ULONG *pDataSize, void *pDataBuffer, HRESULT hrFault);

protected:
	GUID			m_Guid;
	_bstr_t			m_sDescription;
	_bstr_t			m_sSource;
	_bstr_t			m_sHelpFile;
	DWORD			m_dwHelpContext;
};

/*
typedef struct tagSTDOBJREF
{
	unsigned long flags;
	unsigned long cPublicRefs;
	OXID oxid;
	OID oid;
	IPID ipid;
} STDOBJREF;

typedef struct tagDUALSTRINGARRAY
{
	unsigned short wNumEntries;
	unsigned short wSecurityOffset;
	unsigned short aStringArray[];
} DUALSTRINGARRAY;
*/

typedef struct tagOBJREF
{
	unsigned long signature;
	unsigned long flags;
	GUID iid;

	union
	{
/*
		struct
		{
			STDOBJREF std;
			DUALSTRINGARRAY saResAddr;
		} u_standard;

		struct
		{
			STDOBJREF std;
			CLSID clsid;
			DUALSTRINGARRAY saResAddr;
		} u_handler;
*/
		struct
		{
			CLSID clsid;
			unsigned long cbExtension;
			unsigned long size;
			byte Data;
		} u_custom;
	} u_objref;
} OBJREF;

bool StartChannelHook (void);
bool StopChannelHook (void);

#endif

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)

About the Author

Werner Willemsens
Team Leader
Belgium Belgium
No Biography provided

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