How to access COM objects during runtime?
-
Hi, I need to access COM objects during runtime or dynamically using VC++6. Can somebody please help me in this? Is there a way I can call the COM objects during runtime by entering the GUID or something like that? I am a beginner in COM.. Thx!!
-
Hi, I need to access COM objects during runtime or dynamically using VC++6. Can somebody please help me in this? Is there a way I can call the COM objects during runtime by entering the GUID or something like that? I am a beginner in COM.. Thx!!
-
Hi, I need to access COM objects during runtime or dynamically using VC++6. Can somebody please help me in this? Is there a way I can call the COM objects during runtime by entering the GUID or something like that? I am a beginner in COM.. Thx!!
Hi there, :) One can access COM objects at run time , but the interface supported by this COM object should support IDispatch interface. CLSID objClsid; // initialize your obj CLSID in this variable using CoCreateInstance() get the IDispatch pointer. IDispatch *dispPtr; CoCreateInstance(objClsid, NULL, CLSCTX_ALL, IID_IDispatch , (void **) &dispPtr); if your object support IDispatch interface , it will return its instance , else it will return NULL. now using this dispPtr and IDispatch int isInfoAvailable; dispPtr->GetTypeInfoCount(&isInfoAvailable); if isInfoAvailable = 0 , that means this object does not provide run time type information of interfaces it supports. if isInfoAvailable = 1 , that mean now you can query for ITypeInfo interface pointer for getting information about the interface this object supports. now using GetTypeInfo() method you can further query for ITypeInfo interface , using which you can browse all the interface and methods of these interface supported by your COM object. and then using Invoke and GetIDsOfName methods of IDispatch you can also execute your method at run time. Regards Abhishek Srivastava Software Engg (VC++) India ,Noida Mobile no 9891492921 :)
-
Hi there, :) One can access COM objects at run time , but the interface supported by this COM object should support IDispatch interface. CLSID objClsid; // initialize your obj CLSID in this variable using CoCreateInstance() get the IDispatch pointer. IDispatch *dispPtr; CoCreateInstance(objClsid, NULL, CLSCTX_ALL, IID_IDispatch , (void **) &dispPtr); if your object support IDispatch interface , it will return its instance , else it will return NULL. now using this dispPtr and IDispatch int isInfoAvailable; dispPtr->GetTypeInfoCount(&isInfoAvailable); if isInfoAvailable = 0 , that means this object does not provide run time type information of interfaces it supports. if isInfoAvailable = 1 , that mean now you can query for ITypeInfo interface pointer for getting information about the interface this object supports. now using GetTypeInfo() method you can further query for ITypeInfo interface , using which you can browse all the interface and methods of these interface supported by your COM object. and then using Invoke and GetIDsOfName methods of IDispatch you can also execute your method at run time. Regards Abhishek Srivastava Software Engg (VC++) India ,Noida Mobile no 9891492921 :)