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

Understanding The COM Single-Threaded Apartment Part 1

, 6 Jan 2005 CPOL
Learn the fundamental principles of the COM Single-Threaded Apartment Model by code examples.
ccomthread_src.zip
LegacyCOMObject1
Shared
SimpleCOMObject1
SimpleCOMObject2
Test Programs
LegacyCOMObject1.def
LegacyCOMObject1.dsp
LegacyCOMObject1.dsw
LegacyCOMObject1.rgs
LegacyCOMObject1.tlb
LegacyCOMObject1ps.def
LegacyCOMObject1ps.mk
SimpleCOMObject1.def
SimpleCOMObject1.dsp
SimpleCOMObject1.dsw
SimpleCOMObject1.rgs
SimpleCOMObject1.tlb
SimpleCOMObject1ps.def
SimpleCOMObject1ps.mk
SimpleCOMObject2.def
SimpleCOMObject2.dsp
SimpleCOMObject2.dsw
SimpleCOMObject2.rgs
SimpleCOMObject2.tlb
SimpleCOMObject2ps.def
SimpleCOMObject2ps.mk
VBTest
VCTests
FormMain.frm
MSSCCPRJ.SCC
VBTest.exe
VBTest.vbp
VBTest.vbw
DemonstrateDefaultSTA
DemonstrateExeServerSTA
DemonstrateLegacySTA
DemonstrateNoMessageLoop
DemonstrateSTA
VCTest01
VCTest02
SimpleCOMObject2.tlh
SimpleCOMObject2.tli
VCTest01.dsp
VCTest01.dsw
SimpleCOMObject2.tlh
SimpleCOMObject2.tli
VCTest02.dsp
VCTest02.dsw
Client
Implementation
Interface
VCTest01
VCTest01.dsp
VCTest01.dsw
ExeServerImpl
ExeServerImpl.dsp
ExeServerImpl.dsw
ExeServerInterfaces
ExeObj01.rgs
ExeObj02.rgs
ExeObj03.rgs
ExeServerInterfaces.def
ExeServerInterfaces.dsp
ExeServerInterfaces.dsw
ExeServerInterfaces.tlb
ExeServerInterfacesps.def
ExeServerInterfacesps.mk
VCTest01
VCTest02
LegacyCOMObject1.tlh
LegacyCOMObject1.tli
VCTest01.dsp
VCTest01.dsw
VCTest02.dsp
VCTest02.dsw
VCTest01
SimpleCOMObject2.tlh
SimpleCOMObject2.tli
VCTest01.dsp
VCTest01.dsw
VCTest01
SimpleCOMObject2.tlh
SimpleCOMObject2.tli
VCTest01.dsp
VCTest01.dsw
/* 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)

Share

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
Web02 | 2.8.141015.1 | Last Updated 6 Jan 2005
Article Copyright 2005 by Lim Bio Liong
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid