Reputation: 841
I have to call a COM component from C done in Visual Studio. I am able to call it from Visual C++ using the '#import' directive by specifying the .tlb file. But I don't see #import directive in the C language. Is there an alternative I can use instead of that?
I cannot write in C++ as I have to create the module in pure C only.
Upvotes: 3
Views: 2219
Reputation: 432
Ok, you should (in brief):
Here it is the complete, step by step solution for your question: http://www.codeproject.com/Articles/632616/How-to-use-NET-Csharp-COM-objects-in-plain-C
Upvotes: 1
Reputation: 170489
The type library in that component likely comes from compiling a IDL file by MIDL. MIDL produces three files - .tlb, .c and .h. .c and .h files contain interface definitions for C and C++ - there's a gazillion of #ifdef __cplusplus
to provide identical definitions - one set is for C and another one is for C++.
You have to get those .c and .h files and include into your project. If you have the COM component sources - get those files after building the component. If it's shipped by a third party - contact them and ask them to publish those files.
Upvotes: 0