Click here to Skip to main content
16,006,531 members
Home / Discussions / COM
   

COM

 
GeneralSAFEARRAY in Variant Pin
Hans Ruck26-Jun-02 5:18
Hans Ruck26-Jun-02 5:18 
GeneralRe: SAFEARRAY in Variant Pin
Ramu Pulipati26-Jun-02 6:24
Ramu Pulipati26-Jun-02 6:24 
GeneralDCOM port restriction Pin
MrGlover24-Jun-02 13:46
MrGlover24-Jun-02 13:46 
GeneralCOM Exe that "stays" Pin
[Shadow]24-Jun-02 2:28
[Shadow]24-Jun-02 2:28 
GeneralRe: COM Exe that "stays" Pin
Ernest Laurentin24-Jun-02 4:29
Ernest Laurentin24-Jun-02 4:29 
GeneralRe: COM Exe that "stays" Pin
Jason Henderson24-Jun-02 9:16
Jason Henderson24-Jun-02 9:16 
GeneralRef to ActiveX control using C Pin
JohnnyG23-Jun-02 14:17
JohnnyG23-Jun-02 14:17 
GeneralRe: Ref to ActiveX control using C Pin
soptest24-Jun-02 8:30
soptest24-Jun-02 8:30 
Example how to work with COM in "C":
/* main.c */
//other headers here ...
//... 
#inluce "windows.h"
#include "objx\\objx.h"
//"objX" is a test object

int main(int argc, char* argv[])
{
	IObj *pObj;
	HRESULT hr;
	BSTR wsIn;

	CoInitialize(0);
	
	hr = CoCreateInstance( &CLSID_Obj, 0, CLSCTX_SERVER, &IID_IObj, (void**) &pObj);
	
	if(S_OK == hr)
	{
		
		wsIn = SysAllocString(L"Test string.");
		//all calls made using vtbl 
		hr = pObj->lpVtbl->Test(pObj,wsIn);
		//see objX.h file for declaration of IObj interface	
		pObj->lpVtbl->Release(pObj);

		SysFreeString(wsIn);
	}
	

	CoUninitialize();
}

must link with "ObjX_i.c" .


This is my test object header file:
#pragma warning( disable: 4049 )  /* more than 64k source lines */

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


 /* File created by MIDL compiler version 5.03.0280 */
/* at Mon Jun 24 10:55:15 2002
 */
/* Compiler settings for C:\TEMP\tt\objX\objX.idl:
    Oicf (OptLev=i2), W1, Zp8, env=Win32 (32b run), ms_ext, c_ext
    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(  )


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

/* Forward Declarations */ 

#ifndef __IObj_FWD_DEFINED__
#define __IObj_FWD_DEFINED__
typedef interface IObj IObj;
#endif 	/* __IObj_FWD_DEFINED__ */


#ifndef __Obj_FWD_DEFINED__
#define __Obj_FWD_DEFINED__

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

#endif 	/* __Obj_FWD_DEFINED__ */


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

#ifdef __cplusplus
extern "C"{
#endif 

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

#ifndef __IObj_INTERFACE_DEFINED__
#define __IObj_INTERFACE_DEFINED__

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


EXTERN_C const IID IID_IObj;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    MIDL_INTERFACE("3257037D-879B-11D6-A117-00B0D0C3D9BD")
    IObj : public IDispatch
    {
    public:
        virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE Test( 
            /* [in] */ BSTR wsIn) = 0;
        
    };
    
#else 	
^__b style='{ color:blue }'>
    typedef struct IObjVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IObj __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IObj __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IObj __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )( 
            IObj __RPC_FAR * This,
            /* [out] */ UINT __RPC_FAR *pctinfo);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )( 
            IObj __RPC_FAR * This,
            /* [in] */ UINT iTInfo,
            /* [in] */ LCID lcid,
            /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )( 
            IObj __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 )( 
            IObj __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 *Test )( 
            IObj __RPC_FAR * This,
            /* [in] */ BSTR wsIn);
        
        END_INTERFACE
    } IObjVtbl;

    interface IObj
    {
        CONST_VTBL struct IObjVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


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

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

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


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

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

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

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


#define IObj_Test(This,wsIn)	\
    (This)->lpVtbl -> Test(This,wsIn)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [helpstring][id] */ HRESULT STDMETHODCALLTYPE IObj_Test_Proxy( 
    IObj __RPC_FAR * This,
    /* [in] */ BSTR wsIn);


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



#endif 	/* __IObj_INTERFACE_DEFINED__ */



#ifndef __OBJXLib_LIBRARY_DEFINED__
#define __OBJXLib_LIBRARY_DEFINED__

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


EXTERN_C const IID LIBID_OBJXLib;

EXTERN_C const CLSID CLSID_Obj;

#ifdef __cplusplus

class DECLSPEC_UUID("3257037E-879B-11D6-A117-00B0D0C3D9BD")
Obj;
#endif
#endif /* __OBJXLib_LIBRARY_DEFINED__ */

/* Additional Prototypes for ALL interfaces */

unsigned long             __RPC_USER  BSTR_UserSize(     unsigned long __RPC_FAR *, unsigned long            , BSTR __RPC_FAR * ); 
unsigned char __RPC_FAR * __RPC_USER  BSTR_UserMarshal(  unsigned long __RPC_FAR *, unsigned char __RPC_FAR *, BSTR __RPC_FAR * ); 
unsigned char __RPC_FAR * __RPC_USER  BSTR_UserUnmarshal(unsigned long __RPC_FAR *, unsigned char __RPC_FAR *, BSTR __RPC_FAR * ); 
void                      __RPC_USER  BSTR_UserFree(     unsigned long __RPC_FAR *, BSTR __RPC_FAR * ); 

/* end of Additional Prototypes */

#ifdef __cplusplus
}
#endif

#endif


soptest
GeneralRe: Ref to ActiveX control using C Pin
JohnnyG24-Jun-02 8:59
JohnnyG24-Jun-02 8:59 
GeneralRe: Ref to ActiveX control using C Pin
soptest24-Jun-02 9:21
soptest24-Jun-02 9:21 
GeneralRe: Ref to ActiveX control using C Pin
JohnnyG30-Jun-02 14:31
JohnnyG30-Jun-02 14:31 
GeneralRe: Ref to ActiveX control using C Pin
Amit Dey1-Jul-02 6:44
Amit Dey1-Jul-02 6:44 
QuestionActiveX is "unsafe" huh? Pin
Philip Patrick22-Jun-02 6:08
professionalPhilip Patrick22-Jun-02 6:08 
AnswerRe: ActiveX is "unsafe" huh? Pin
Michael Dunn22-Jun-02 6:50
sitebuilderMichael Dunn22-Jun-02 6:50 
GeneralDCom-security question.... Pin
stefanb22-Jun-02 5:27
stefanb22-Jun-02 5:27 
GeneralRe: DCom-security question.... Pin
Jason Henderson24-Jun-02 9:20
Jason Henderson24-Jun-02 9:20 
GeneralRe: DCom-security question.... Pin
stefanb24-Jun-02 9:58
stefanb24-Jun-02 9:58 
GeneralThis one is easy! Pin
Al_Pennyworth21-Jun-02 8:24
Al_Pennyworth21-Jun-02 8:24 
GeneralDifferent Kind of problem Pin
Al_Pennyworth20-Jun-02 8:46
Al_Pennyworth20-Jun-02 8:46 
QuestionAny Idea? Pin
Al_Pennyworth20-Jun-02 4:27
Al_Pennyworth20-Jun-02 4:27 
AnswerRe: Any Idea? Pin
Rama Krishna Vavilala20-Jun-02 8:02
Rama Krishna Vavilala20-Jun-02 8:02 
GeneralRe: Any Idea? Pin
Al_Pennyworth24-Jun-02 7:05
Al_Pennyworth24-Jun-02 7:05 
AnswerRe: Any Idea? Pin
Amit Dey1-Jul-02 3:35
Amit Dey1-Jul-02 3:35 
GeneralRe: Any Idea? Pin
1-Jul-02 7:31
suss1-Jul-02 7:31 
AnswerRe: Any Idea? Pin
Amit Dey27-Aug-02 13:49
Amit Dey27-Aug-02 13:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.