?
Solved

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

Posted on 2004-03-25
2
Medium Priority
?
246 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 750 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

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
There's never been a better time to become a computer scientist. Employment growth in the field is expected to reach 22% overall by 2020, and if you want to get in on the action, it’s a good idea to think about at least minoring in computer science …
The goal of this video is to provide viewers with basic examples to understand and use pointers 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.

568 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