Solved

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

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
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…
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.

747 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

11 Experts available now in Live!

Get 1:1 Help Now