Click here to Skip to main content
15,885,209 members
Articles / Desktop Programming / ATL

Understanding The COM Single-Threaded Apartment Part 1

Rate me:
Please Sign up or sign in to vote.
4.95/5 (206 votes)
6 Jan 2005CPOL49 min read 842.2K   4.9K   442  
Learn the fundamental principles of the COM Single-Threaded Apartment Model by code examples.
/* this ALWAYS GENERATED file contains the definitions for the interfaces */


/* File created by MIDL compiler version 5.01.0164 */
/* at Sun Dec 19 19:43:53 2004
 */
/* Compiler settings for C:\Limbl\Develope\CodeProject\CCOMThread\SimpleCOMObject1\SimpleCOMObject1.idl:
    Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext
    error checks: allocation ref bounds_check enum stub_data 
*/
//@@MIDL_FILE_HEADING(  )


/* verify that the <rpcndr.h> version is high enough to compile this file*/
#ifndef __REQUIRED_RPCNDR_H_VERSION__
#define __REQUIRED_RPCNDR_H_VERSION__ 440
#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 __SimpleCOMObject1_h__
#define __SimpleCOMObject1_h__

#ifdef __cplusplus
extern "C"{
#endif 

/* Forward Declarations */ 

#ifndef __ISimpleCOMObject1_FWD_DEFINED__
#define __ISimpleCOMObject1_FWD_DEFINED__
typedef interface ISimpleCOMObject1 ISimpleCOMObject1;
#endif 	/* __ISimpleCOMObject1_FWD_DEFINED__ */


#ifndef ___ISimpleCOMObject1Events_FWD_DEFINED__
#define ___ISimpleCOMObject1Events_FWD_DEFINED__
typedef interface _ISimpleCOMObject1Events _ISimpleCOMObject1Events;
#endif 	/* ___ISimpleCOMObject1Events_FWD_DEFINED__ */


#ifndef __SimpleCOMObject1_FWD_DEFINED__
#define __SimpleCOMObject1_FWD_DEFINED__

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

#endif 	/* __SimpleCOMObject1_FWD_DEFINED__ */


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

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

#ifndef __ISimpleCOMObject1_INTERFACE_DEFINED__
#define __ISimpleCOMObject1_INTERFACE_DEFINED__

/* interface ISimpleCOMObject1 */
/* [unique][helpstring][dual][uuid][object] */ 


EXTERN_C const IID IID_ISimpleCOMObject1;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    MIDL_INTERFACE("96A34C8B-E166-41EB-A390-9F9845F40D9F")
    ISimpleCOMObject1 : public IDispatch
    {
    public:
        virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE Initialize( void) = 0;
        
        virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE Uninitialize( void) = 0;
        
        virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE DoLengthyFunction( 
            /* [in] */ long lTimeout) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct ISimpleCOMObject1Vtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            ISimpleCOMObject1 __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            ISimpleCOMObject1 __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            ISimpleCOMObject1 __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )( 
            ISimpleCOMObject1 __RPC_FAR * This,
            /* [out] */ UINT __RPC_FAR *pctinfo);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )( 
            ISimpleCOMObject1 __RPC_FAR * This,
            /* [in] */ UINT iTInfo,
            /* [in] */ LCID lcid,
            /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )( 
            ISimpleCOMObject1 __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,
            /* [in] */ UINT cNames,
            /* [in] */ LCID lcid,
            /* [size_is][out] */ DISPID __RPC_FAR *rgDispId);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Invoke )( 
            ISimpleCOMObject1 __RPC_FAR * This,
            /* [in] */ DISPID dispIdMember,
            /* [in] */ REFIID riid,
            /* [in] */ LCID lcid,
            /* [in] */ WORD wFlags,
            /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,
            /* [out] */ VARIANT __RPC_FAR *pVarResult,
            /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
            /* [out] */ UINT __RPC_FAR *puArgErr);
        
        /* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Initialize )( 
            ISimpleCOMObject1 __RPC_FAR * This);
        
        /* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Uninitialize )( 
            ISimpleCOMObject1 __RPC_FAR * This);
        
        /* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *DoLengthyFunction )( 
            ISimpleCOMObject1 __RPC_FAR * This,
            /* [in] */ long lTimeout);
        
        END_INTERFACE
    } ISimpleCOMObject1Vtbl;

    interface ISimpleCOMObject1
    {
        CONST_VTBL struct ISimpleCOMObject1Vtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


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

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

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


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

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

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

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


#define ISimpleCOMObject1_Initialize(This)	\
    (This)->lpVtbl -> Initialize(This)

#define ISimpleCOMObject1_Uninitialize(This)	\
    (This)->lpVtbl -> Uninitialize(This)

#define ISimpleCOMObject1_DoLengthyFunction(This,lTimeout)	\
    (This)->lpVtbl -> DoLengthyFunction(This,lTimeout)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ISimpleCOMObject1_Initialize_Proxy( 
    ISimpleCOMObject1 __RPC_FAR * This);


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


/* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ISimpleCOMObject1_Uninitialize_Proxy( 
    ISimpleCOMObject1 __RPC_FAR * This);


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


/* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ISimpleCOMObject1_DoLengthyFunction_Proxy( 
    ISimpleCOMObject1 __RPC_FAR * This,
    /* [in] */ long lTimeout);


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



#endif 	/* __ISimpleCOMObject1_INTERFACE_DEFINED__ */



#ifndef __SIMPLECOMOBJECT1Lib_LIBRARY_DEFINED__
#define __SIMPLECOMOBJECT1Lib_LIBRARY_DEFINED__

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


EXTERN_C const IID LIBID_SIMPLECOMOBJECT1Lib;

#ifndef ___ISimpleCOMObject1Events_DISPINTERFACE_DEFINED__
#define ___ISimpleCOMObject1Events_DISPINTERFACE_DEFINED__

/* dispinterface _ISimpleCOMObject1Events */
/* [helpstring][uuid] */ 


EXTERN_C const IID DIID__ISimpleCOMObject1Events;

#if defined(__cplusplus) && !defined(CINTERFACE)

    MIDL_INTERFACE("8B88E59A-4BB7-4DBC-819A-2E682845A4AE")
    _ISimpleCOMObject1Events : public IDispatch
    {
    };
    
#else 	/* C style interface */

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

    interface _ISimpleCOMObject1Events
    {
        CONST_VTBL struct _ISimpleCOMObject1EventsVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


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

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

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


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

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

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

#define _ISimpleCOMObject1Events_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 	/* ___ISimpleCOMObject1Events_DISPINTERFACE_DEFINED__ */


EXTERN_C const CLSID CLSID_SimpleCOMObject1;

#ifdef __cplusplus

class DECLSPEC_UUID("11EF2E3F-9887-4530-8EE0-D8A57D69653A")
SimpleCOMObject1;
#endif
#endif /* __SIMPLECOMOBJECT1Lib_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