Solved

Linking a C program with a COM (component object model) library

Posted on 2004-03-25
2
214 Views
Last Modified: 2008-02-01
Hi,
I am writing a program in C (can not use anything else due to limitations of the application) and I have to make calls to a COM library, but I can't a find a way to link these programs or to make a call from the C program to the COM library.

Does anyone know how to do it?

Thanks,

Rocky
0
Comment
Question by:rocharodo
2 Comments
 
LVL 5

Accepted Solution

by:
millsoft earned 250 total points
ID: 10683733
I strongly suggest you find the book "Inside OLE" by Kraig Brockshmidt.  It will explain it in good detail.  I think the book is out of print, so you'll probably have to get a used copy.

You don't directly link your 'C' code to COM objects.  You load COM objects at run time with the CoCreateInstance family of Windows API functions.  (I'm assuming you're working on Windows, since that is where COM usually shows up.)  If you are in a different environment, your environment will have similar functions to load the COM objects.

Basically when you call CoCreateInstance, you get a pointer to an structure of function pointers that you use to call functions on the COM objects.  

The main chapters in Kraig's book you will need are Chapters 1 & 2 -- it's about 140 pages of highly technical stuff, so I really, REALLY suggest you get a copy.

Hope this helps.

Brad

P.S. can you explain the limits of your app that require 'C'?

0
 

Author Comment

by:rocharodo
ID: 10858207
Brad,
thanks for the info, I finally got the book that you suggested and looks very interesting.

I have also found the following website http://www.cascadia.ctc.edu/facultyweb/instructors/mpanitz/COM_Tutorial/COMClientInC.html

it explains in very details what I am trying to do.

thanks

Rodolfo
0

Featured Post

Network it in WD Red

There's an industry-leading WD Red drive for every compatible NAS system to help fulfill your data storage needs. With drives up to 8TB, WD Red offers a wide array of solutions for customers looking to build the biggest, best-performing NAS storage solution.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now