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

Understanding Custom Marshaling Part 1

, 18 Aug 2006
Learn the fundamental principles of COM custom marshaling by code examples.
Prize winner in Competition "MFC/C++ Jul 2006"
custommarshaling01_src.zip
utilities
BasicSample01
Interfaces
Implementations
Clients
BasicSample01Interfaces
BasicSample01Interfaces.aps
BasicSample01Interfaces.def
BasicSample01Interfaces.ncb
BasicSample01Interfaces.rgs
BasicSample01Interfacesps.def
Immutable.rgs
ImmutableObjectFactory.rgs
BasicSample01Interfaces.vcproj.vspscc
BasicSample01InterfacesPS.vcproj.vspscc
BasicSample01InterfacesImpl
BasicSample01InterfacesImpl.aps
BasicSample01InterfacesImpl.def
BasicSample01InterfacesImpl.rgs
BasicSample01InterfacesImplps.def
ImmutableImpl.rgs
ImmutableObjectFactoryImpl.rgs
BasicSample01InterfacesImpl.ncb
BasicSample01InterfacesImpl.vcproj.vspscc
BasicSample01InterfacesImplPS.vcproj.vspscc
VCConsoleClient01
VCConsoleClient03
VCConsoleClient02
VCConsoleClient01.ncb
VCConsoleClient03.ncb
VCConsoleClient02.ncb

/* this ALWAYS GENERATED file contains the definitions for the interfaces */


 /* File created by MIDL compiler version 6.00.0361 */
/* at Sat Aug 19 02:53:28 2006
 */
/* Compiler settings for .\BasicSample01Interfaces.idl:
    Oicf, W1, Zp8, env=Win32 (32b run)
    protocol : dce , ms_ext, c_ext, robust
    error checks: allocation ref bounds_check enum stub_data 
    VC __declspec() decoration level: 
         __declspec(uuid()), __declspec(selectany), __declspec(novtable)
         DECLSPEC_UUID(), MIDL_INTERFACE()
*/
//@@MIDL_FILE_HEADING(  )

#pragma warning( disable: 4049 )  /* more than 64k source lines */


/* verify that the <rpcndr.h> version is high enough to compile this file*/
#ifndef __REQUIRED_RPCNDR_H_VERSION__
#define __REQUIRED_RPCNDR_H_VERSION__ 475
#endif

#include "rpc.h"
#include "rpcndr.h"

#ifndef __RPCNDR_H_VERSION__
#error this stub requires an updated version of <rpcndr.h>
#endif // __RPCNDR_H_VERSION__

#ifndef COM_NO_WINDOWS_H
#include "windows.h"
#include "ole2.h"
#endif /*COM_NO_WINDOWS_H*/

#ifndef __BasicSample01Interfaces_h__
#define __BasicSample01Interfaces_h__

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif

/* Forward Declarations */ 

#ifndef __IImmutable_FWD_DEFINED__
#define __IImmutable_FWD_DEFINED__
typedef interface IImmutable IImmutable;
#endif 	/* __IImmutable_FWD_DEFINED__ */


#ifndef __IImmutableObjectFactory_FWD_DEFINED__
#define __IImmutableObjectFactory_FWD_DEFINED__
typedef interface IImmutableObjectFactory IImmutableObjectFactory;
#endif 	/* __IImmutableObjectFactory_FWD_DEFINED__ */


#ifndef __Immutable_FWD_DEFINED__
#define __Immutable_FWD_DEFINED__

#ifdef __cplusplus
typedef class Immutable Immutable;
#else
typedef struct Immutable Immutable;
#endif /* __cplusplus */

#endif 	/* __Immutable_FWD_DEFINED__ */


#ifndef __ImmutableObjectFactory_FWD_DEFINED__
#define __ImmutableObjectFactory_FWD_DEFINED__

#ifdef __cplusplus
typedef class ImmutableObjectFactory ImmutableObjectFactory;
#else
typedef struct ImmutableObjectFactory ImmutableObjectFactory;
#endif /* __cplusplus */

#endif 	/* __ImmutableObjectFactory_FWD_DEFINED__ */


/* header files for imported files */
#include "oaidl.h"
#include "ocidl.h"

#ifdef __cplusplus
extern "C"{
#endif 

void * __RPC_USER MIDL_user_allocate(size_t);
void __RPC_USER MIDL_user_free( void * ); 

#ifndef __IImmutable_INTERFACE_DEFINED__
#define __IImmutable_INTERFACE_DEFINED__

/* interface IImmutable */
/* [unique][helpstring][nonextensible][dual][uuid][object] */ 


EXTERN_C const IID IID_IImmutable;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    MIDL_INTERFACE("BF0DC81A-46FB-4300-88E5-2B8EEB2CEEA1")
    IImmutable : public IDispatch
    {
    public:
        virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_LongValue( 
            /* [retval][out] */ LONG *pVal) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IImmutableVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
            IImmutable * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void **ppvObject);
        
        ULONG ( STDMETHODCALLTYPE *AddRef )( 
            IImmutable * This);
        
        ULONG ( STDMETHODCALLTYPE *Release )( 
            IImmutable * This);
        
        HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( 
            IImmutable * This,
            /* [out] */ UINT *pctinfo);
        
        HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( 
            IImmutable * This,
            /* [in] */ UINT iTInfo,
            /* [in] */ LCID lcid,
            /* [out] */ ITypeInfo **ppTInfo);
        
        HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( 
            IImmutable * This,
            /* [in] */ REFIID riid,
            /* [size_is][in] */ LPOLESTR *rgszNames,
            /* [in] */ UINT cNames,
            /* [in] */ LCID lcid,
            /* [size_is][out] */ DISPID *rgDispId);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( 
            IImmutable * This,
            /* [in] */ DISPID dispIdMember,
            /* [in] */ REFIID riid,
            /* [in] */ LCID lcid,
            /* [in] */ WORD wFlags,
            /* [out][in] */ DISPPARAMS *pDispParams,
            /* [out] */ VARIANT *pVarResult,
            /* [out] */ EXCEPINFO *pExcepInfo,
            /* [out] */ UINT *puArgErr);
        
        /* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_LongValue )( 
            IImmutable * This,
            /* [retval][out] */ LONG *pVal);
        
        END_INTERFACE
    } IImmutableVtbl;

    interface IImmutable
    {
        CONST_VTBL struct IImmutableVtbl *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IImmutable_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IImmutable_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IImmutable_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IImmutable_GetTypeInfoCount(This,pctinfo)	\
    (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)

#define IImmutable_GetTypeInfo(This,iTInfo,lcid,ppTInfo)	\
    (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)

#define IImmutable_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)	\
    (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)

#define IImmutable_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)	\
    (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)


#define IImmutable_get_LongValue(This,pVal)	\
    (This)->lpVtbl -> get_LongValue(This,pVal)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE IImmutable_get_LongValue_Proxy( 
    IImmutable * This,
    /* [retval][out] */ LONG *pVal);


void __RPC_STUB IImmutable_get_LongValue_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IImmutable_INTERFACE_DEFINED__ */


#ifndef __IImmutableObjectFactory_INTERFACE_DEFINED__
#define __IImmutableObjectFactory_INTERFACE_DEFINED__

/* interface IImmutableObjectFactory */
/* [unique][helpstring][nonextensible][dual][uuid][object] */ 


EXTERN_C const IID IID_IImmutableObjectFactory;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    MIDL_INTERFACE("CCAB57EA-A497-44C0-B0A4-E781B7F47AA9")
    IImmutableObjectFactory : public IDispatch
    {
    public:
        virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE CreateObject( 
            /* [in] */ LONG InitializationValue,
            /* [retval][out] */ IImmutable **ppIImmutableObjectReceiver) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IImmutableObjectFactoryVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
            IImmutableObjectFactory * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void **ppvObject);
        
        ULONG ( STDMETHODCALLTYPE *AddRef )( 
            IImmutableObjectFactory * This);
        
        ULONG ( STDMETHODCALLTYPE *Release )( 
            IImmutableObjectFactory * This);
        
        HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( 
            IImmutableObjectFactory * This,
            /* [out] */ UINT *pctinfo);
        
        HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( 
            IImmutableObjectFactory * This,
            /* [in] */ UINT iTInfo,
            /* [in] */ LCID lcid,
            /* [out] */ ITypeInfo **ppTInfo);
        
        HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( 
            IImmutableObjectFactory * This,
            /* [in] */ REFIID riid,
            /* [size_is][in] */ LPOLESTR *rgszNames,
            /* [in] */ UINT cNames,
            /* [in] */ LCID lcid,
            /* [size_is][out] */ DISPID *rgDispId);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( 
            IImmutableObjectFactory * This,
            /* [in] */ DISPID dispIdMember,
            /* [in] */ REFIID riid,
            /* [in] */ LCID lcid,
            /* [in] */ WORD wFlags,
            /* [out][in] */ DISPPARAMS *pDispParams,
            /* [out] */ VARIANT *pVarResult,
            /* [out] */ EXCEPINFO *pExcepInfo,
            /* [out] */ UINT *puArgErr);
        
        /* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *CreateObject )( 
            IImmutableObjectFactory * This,
            /* [in] */ LONG InitializationValue,
            /* [retval][out] */ IImmutable **ppIImmutableObjectReceiver);
        
        END_INTERFACE
    } IImmutableObjectFactoryVtbl;

    interface IImmutableObjectFactory
    {
        CONST_VTBL struct IImmutableObjectFactoryVtbl *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IImmutableObjectFactory_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IImmutableObjectFactory_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IImmutableObjectFactory_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IImmutableObjectFactory_GetTypeInfoCount(This,pctinfo)	\
    (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)

#define IImmutableObjectFactory_GetTypeInfo(This,iTInfo,lcid,ppTInfo)	\
    (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)

#define IImmutableObjectFactory_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)	\
    (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)

#define IImmutableObjectFactory_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)	\
    (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)


#define IImmutableObjectFactory_CreateObject(This,InitializationValue,ppIImmutableObjectReceiver)	\
    (This)->lpVtbl -> CreateObject(This,InitializationValue,ppIImmutableObjectReceiver)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [helpstring][id] */ HRESULT STDMETHODCALLTYPE IImmutableObjectFactory_CreateObject_Proxy( 
    IImmutableObjectFactory * This,
    /* [in] */ LONG InitializationValue,
    /* [retval][out] */ IImmutable **ppIImmutableObjectReceiver);


void __RPC_STUB IImmutableObjectFactory_CreateObject_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IImmutableObjectFactory_INTERFACE_DEFINED__ */



#ifndef __BasicSample01InterfacesLib_LIBRARY_DEFINED__
#define __BasicSample01InterfacesLib_LIBRARY_DEFINED__

/* library BasicSample01InterfacesLib */
/* [helpstring][version][uuid] */ 


EXTERN_C const IID LIBID_BasicSample01InterfacesLib;

EXTERN_C const CLSID CLSID_Immutable;

#ifdef __cplusplus

class DECLSPEC_UUID("5F2C7BC5-0455-422A-B244-D1132C07218C")
Immutable;
#endif

EXTERN_C const CLSID CLSID_ImmutableObjectFactory;

#ifdef __cplusplus

class DECLSPEC_UUID("7324F66F-3F41-4BA9-8426-3D1B5DE4DD9C")
ImmutableObjectFactory;
#endif
#endif /* __BasicSample01InterfacesLib_LIBRARY_DEFINED__ */

/* Additional Prototypes for ALL interfaces */

/* end of Additional Prototypes */

#ifdef __cplusplus
}
#endif

#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

Lim Bio Liong
Web Developer
Singapore Singapore
Lim Bio Liong is a Specialist at a leading Software House in Singapore.
 
Bio has been in software development for over 10 years. He specialises in C/C++ programming and Windows software development.
 
Bio has also done device-driver development and enjoys low-level programming. Bio has recently picked up C# programming and has been researching in this area.

| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 18 Aug 2006
Article Copyright 2006 by Lim Bio Liong
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid