Solved

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

Posted on 2004-03-25
2
220 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

806 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