How to Rreference COM object(tlb file) in VC++
-
Hi All, I have generated a tlb file through idl for the implementation of COM. I want to use this COM object in my VC++ code. Anybody know how to reference tlb file in VC++ code. For VB I can directly reference the tlb file, but I dont dont know is there any way we can reference tlb file in my VC++ code and start using the methods inside COM object Thanks in Advance JK
-
Hi All, I have generated a tlb file through idl for the implementation of COM. I want to use this COM object in my VC++ code. Anybody know how to reference tlb file in VC++ code. For VB I can directly reference the tlb file, but I dont dont know is there any way we can reference tlb file in my VC++ code and start using the methods inside COM object Thanks in Advance JK
-
Hi All, I have generated a tlb file through idl for the implementation of COM. I want to use this COM object in my VC++ code. Anybody know how to reference tlb file in VC++ code. For VB I can directly reference the tlb file, but I dont dont know is there any way we can reference tlb file in my VC++ code and start using the methods inside COM object Thanks in Advance JK
-
You have to import the tlb file to ur VC++ I declare it in header file. #import "C:\myDll\mydll.tlb" raw_interface_only ... .. public Void INiComObj() { CoInitialize(NULL); HRESULT hr = CocreateInstance(CLSID...) }
Hi Sohail, Thanks for the good article. And thanks to pnp for giving the sample code. I did import my tlb file with raw_interface_only option. #import "C:\temp\Mytlb.tlb" raw_interface_only I am facing following compilation error in *.tlh file. error C2504: 'AnyObject' : base class undefined When I see my tlh file my class is deriving from AnyObject base class. I am not sure why it is deriving from AnyObject? Is there any base class "AnyObject" in C++? If yes what are the include files i need to include? Please help me. Thanks in advance. Regards JK
-
Hi Sohail, Thanks for the good article. And thanks to pnp for giving the sample code. I did import my tlb file with raw_interface_only option. #import "C:\temp\Mytlb.tlb" raw_interface_only I am facing following compilation error in *.tlh file. error C2504: 'AnyObject' : base class undefined When I see my tlh file my class is deriving from AnyObject base class. I am not sure why it is deriving from AnyObject? Is there any base class "AnyObject" in C++? If yes what are the include files i need to include? Please help me. Thanks in advance. Regards JK
Hi All, I found out the solution for error C2504: 'AnyObject' : base class undefined My tlb is dependent on some other tlb so, what i did is I #import the base tlb before importing my tlb. It complies fine. There are no errors. But, I am not able to get pointer to my COM object, when I am running following sample code CoInitialize(NULL); IMyComObject pObject(_uuidof(MyComObjectName)); I am getting following error in CoCreateInstance method 0x80040154 Class Not Registered I checked the registry, there is an entry for my typelib. I am not sure why it is not able find the class. Any suggestions/help please.. Thanks in advance JK
-
Hi All, I found out the solution for error C2504: 'AnyObject' : base class undefined My tlb is dependent on some other tlb so, what i did is I #import the base tlb before importing my tlb. It complies fine. There are no errors. But, I am not able to get pointer to my COM object, when I am running following sample code CoInitialize(NULL); IMyComObject pObject(_uuidof(MyComObjectName)); I am getting following error in CoCreateInstance method 0x80040154 Class Not Registered I checked the registry, there is an entry for my typelib. I am not sure why it is not able find the class. Any suggestions/help please.. Thanks in advance JK
Jahnson K wrote:
I am getting following error in CoCreateInstance method 0x80040154 Class Not Registered
The TLB describes the all data of COM server, but there is no code in TLB. You should also register COM server, i.e. EXE or DLL executable module.
With best wishes, Vita
-
Hi All, I have generated a tlb file through idl for the implementation of COM. I want to use this COM object in my VC++ code. Anybody know how to reference tlb file in VC++ code. For VB I can directly reference the tlb file, but I dont dont know is there any way we can reference tlb file in my VC++ code and start using the methods inside COM object Thanks in Advance JK
there are two ways 1)Use #import second you can use the class wizard and refer the tlb file, the wizard will generate the .cli and .clh file containing the wrapper around your COM component Regards, Sunil Tonger
-
Jahnson K wrote:
I am getting following error in CoCreateInstance method 0x80040154 Class Not Registered
The TLB describes the all data of COM server, but there is no code in TLB. You should also register COM server, i.e. EXE or DLL executable module.
With best wishes, Vita