Click here to Skip to main content
15,892,927 members
Articles / Programming Languages / C++

Understanding Custom Marshaling Part 1

Rate me:
Please Sign up or sign in to vote.
4.97/5 (53 votes)
18 Aug 2006CPOL31 min read 208.2K   1.4K   147  
Learn the fundamental principles of COM custom marshaling by code examples.

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


 /* File created by MIDL compiler version 6.00.0361 */
/* at Sat Aug 19 02:54:10 2006
 */
/* Compiler settings for .\BasicSample01InterfacesImpl.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 __BasicSample01InterfacesImpl_h__
#define __BasicSample01InterfacesImpl_h__

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

/* Forward Declarations */ 

#ifndef __IImmutableImpl_FWD_DEFINED__
#define __IImmutableImpl_FWD_DEFINED__
typedef interface IImmutableImpl IImmutableImpl;
#endif 	/* __IImmutableImpl_FWD_DEFINED__ */


#ifndef __IImmutableObjectFactoryImpl_FWD_DEFINED__
#define __IImmutableObjectFactoryImpl_FWD_DEFINED__
typedef interface IImmutableObjectFactoryImpl IImmutableObjectFactoryImpl;
#endif 	/* __IImmutableObjectFactoryImpl_FWD_DEFINED__ */


#ifndef __ImmutableImpl_FWD_DEFINED__
#define __ImmutableImpl_FWD_DEFINED__

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

#endif 	/* __ImmutableImpl_FWD_DEFINED__ */


#ifndef __ImmutableObjectFactoryImpl_FWD_DEFINED__
#define __ImmutableObjectFactoryImpl_FWD_DEFINED__

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

#endif 	/* __ImmutableObjectFactoryImpl_FWD_DEFINED__ */


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

#ifdef __cplusplus
extern "C"{
#endif 

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

#ifndef __IImmutableImpl_INTERFACE_DEFINED__
#define __IImmutableImpl_INTERFACE_DEFINED__

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


EXTERN_C const IID IID_IImmutableImpl;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    MIDL_INTERFACE("9E013477-2A51-490C-B659-A7F6D8C4A032")
    IImmutableImpl : public IDispatch
    {
    public:
    };
    
#else 	/* C style interface */

    typedef struct IImmutableImplVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
            IImmutableImpl * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void **ppvObject);
        
        ULONG ( STDMETHODCALLTYPE *AddRef )( 
            IImmutableImpl * This);
        
        ULONG ( STDMETHODCALLTYPE *Release )( 
            IImmutableImpl * This);
        
        HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( 
            IImmutableImpl * This,
            /* [out] */ UINT *pctinfo);
        
        HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( 
            IImmutableImpl * This,
            /* [in] */ UINT iTInfo,
            /* [in] */ LCID lcid,
            /* [out] */ ITypeInfo **ppTInfo);
        
        HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( 
            IImmutableImpl * This,
            /* [in] */ REFIID riid,
            /* [size_is][in] */ LPOLESTR *rgszNames,
            /* [in] */ UINT cNames,
            /* [in] */ LCID lcid,
            /* [size_is][out] */ DISPID *rgDispId);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( 
            IImmutableImpl * 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);
        
        END_INTERFACE
    } IImmutableImplVtbl;

    interface IImmutableImpl
    {
        CONST_VTBL struct IImmutableImplVtbl *lpVtbl;
    };

    

#ifdef COBJMACROS


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

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

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


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

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

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

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


#endif /* COBJMACROS */


#endif 	/* C style interface */




#endif 	/* __IImmutableImpl_INTERFACE_DEFINED__ */


#ifndef __IImmutableObjectFactoryImpl_INTERFACE_DEFINED__
#define __IImmutableObjectFactoryImpl_INTERFACE_DEFINED__

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


EXTERN_C const IID IID_IImmutableObjectFactoryImpl;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    MIDL_INTERFACE("B1E57E5C-EAB1-4F1A-ADFB-DA6A4A6C4E5F")
    IImmutableObjectFactoryImpl : public IDispatch
    {
    public:
    };
    
#else 	/* C style interface */

    typedef struct IImmutableObjectFactoryImplVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
            IImmutableObjectFactoryImpl * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void **ppvObject);
        
        ULONG ( STDMETHODCALLTYPE *AddRef )( 
            IImmutableObjectFactoryImpl * This);
        
        ULONG ( STDMETHODCALLTYPE *Release )( 
            IImmutableObjectFactoryImpl * This);
        
        HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( 
            IImmutableObjectFactoryImpl * This,
            /* [out] */ UINT *pctinfo);
        
        HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( 
            IImmutableObjectFactoryImpl * This,
            /* [in] */ UINT iTInfo,
            /* [in] */ LCID lcid,
            /* [out] */ ITypeInfo **ppTInfo);
        
        HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( 
            IImmutableObjectFactoryImpl * This,
            /* [in] */ REFIID riid,
            /* [size_is][in] */ LPOLESTR *rgszNames,
            /* [in] */ UINT cNames,
            /* [in] */ LCID lcid,
            /* [size_is][out] */ DISPID *rgDispId);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( 
            IImmutableObjectFactoryImpl * 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);
        
        END_INTERFACE
    } IImmutableObjectFactoryImplVtbl;

    interface IImmutableObjectFactoryImpl
    {
        CONST_VTBL struct IImmutableObjectFactoryImplVtbl *lpVtbl;
    };

    

#ifdef COBJMACROS


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

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

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


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

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

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

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


#endif /* COBJMACROS */


#endif 	/* C style interface */




#endif 	/* __IImmutableObjectFactoryImpl_INTERFACE_DEFINED__ */



#ifndef __BasicSample01InterfacesImplLib_LIBRARY_DEFINED__
#define __BasicSample01InterfacesImplLib_LIBRARY_DEFINED__

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


EXTERN_C const IID LIBID_BasicSample01InterfacesImplLib;

EXTERN_C const CLSID CLSID_ImmutableImpl;

#ifdef __cplusplus

class DECLSPEC_UUID("1EEC87F1-8383-4C13-9E7E-E1BC17BE15B2")
ImmutableImpl;
#endif

EXTERN_C const CLSID CLSID_ImmutableObjectFactoryImpl;

#ifdef __cplusplus

class DECLSPEC_UUID("BDC3F0F2-AE82-4E58-8B4A-FFE24B3E0222")
ImmutableObjectFactoryImpl;
#endif
#endif /* __BasicSample01InterfacesImplLib_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)


Written By
Systems Engineer NEC
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.

Comments and Discussions