How to inerface with COM Objects?
-
Can any body tell me how can i inerface with any COM object? I know GUID/CLSID of he object. I am new with COM Object.
-
Can any body tell me how can i inerface with any COM object? I know GUID/CLSID of he object. I am new with COM Object.
The easiest way is to #import the COM object and use __uuidof to generate instances. If you google __uuidof, you're bound to find heaps of examples. Remember, the objects need to be registered on your machine, if you just have been given them as files, you can't just dump them in a folder. regsvr32 is the command line command to register a COM object. If it's installed with something ( like Office ), then this has been done for you. Christian Graus - Microsoft MVP - C++
-
Can any body tell me how can i inerface with any COM object? I know GUID/CLSID of he object. I am new with COM Object.
There are various libraries that provide classes (and such) to make dealing with COM easier like ATL and the compiler provided COM support classes. Given that you haven't provided much info on this I'll point to at some APIs/interfaces:
CoInitialize
- To initialize COM on the current thread.CoCreateInstance
- Create a registered COM object given a CLSID.IUnknown::QueryInterface
- Get an interface on a COM object given its IID.IDispatch
- For dispatch interfaces. If you're not driving IDispatch interface you will need to have a header file so you can call the methods on the interfaces. There are many ways to do this: - Use one that comes with the component or SDK - Use#import
- If you've got an IDL file, use MIDL to make one. - Use a tool like OleView to make one. Steve -
The easiest way is to #import the COM object and use __uuidof to generate instances. If you google __uuidof, you're bound to find heaps of examples. Remember, the objects need to be registered on your machine, if you just have been given them as files, you can't just dump them in a folder. regsvr32 is the command line command to register a COM object. If it's installed with something ( like Office ), then this has been done for you. Christian Graus - Microsoft MVP - C++
thank u i try for it.
-
There are various libraries that provide classes (and such) to make dealing with COM easier like ATL and the compiler provided COM support classes. Given that you haven't provided much info on this I'll point to at some APIs/interfaces:
CoInitialize
- To initialize COM on the current thread.CoCreateInstance
- Create a registered COM object given a CLSID.IUnknown::QueryInterface
- Get an interface on a COM object given its IID.IDispatch
- For dispatch interfaces. If you're not driving IDispatch interface you will need to have a header file so you can call the methods on the interfaces. There are many ways to do this: - Use one that comes with the component or SDK - Use#import
- If you've got an IDL file, use MIDL to make one. - Use a tool like OleView to make one. SteveBut i have no idea of working with IUnknown. I read so much about this interface in MSDN.
-
But i have no idea of working with IUnknown. I read so much about this interface in MSDN.
IUnknown
has only three methods:QueryInterface
: Get an interface on an object.AddRef
: Call when you copy an interface pointer.Release
: Call when you destroy an interface pointer. I think you should read a good COM tutorial. Steve -
Can any body tell me how can i inerface with any COM object? I know GUID/CLSID of he object. I am new with COM Object.
Hi, To start COM application, you have to know some thing about COM and Interfaces. In VC++, we can do it two ways 1. Using MFC and 2) Using ATL libraries. ATL is simple and wizard faced. All interfaces creation and registration take care by ATL wizards. But in case if MFC, you have to inherit a class from CCmdTarget and create a interface also from IUnknown and IDispatch based upon your need. If you are going to work with on languages like VC++, VB etc then IUnkonwn is enough. But if your COM should support with script languages like VB script, Jscript then You shound use IDispatch. To create simple MFC COM, please go through the below MSDN link.. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncomg/html/msdn\_house2.asp best of luck regards Vallikumar A