NO

Author Topic: How to include MS OLE/COM headers  (Read 3671 times)

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
How to include MS OLE/COM headers
« on: March 30, 2013, 07:26:39 PM »
For those who like to play with OLE/COM.
The zip contains the port to PellesC of one of the examples (scripthost2) of COM in plain C by Jeff Glatt.
Jeff published on codeproject something that can be called a "COM in C bible". Really good job Jeff!!!
Unfortunately not all ole/com header files are present in PellesC distribution, and many unexperienced programmers that want to experiment in this field are thrown away by the huge number of errors that they get when trying to use standard MS headers taken from SDK's.
One of the opinions that PellesC users realize is that the compiler itself is kind of inconpatible compiler, and that MS headers from SDK's are unusable in PellesC. That's definetly not true. The real reason for all that errors is that MS use many bloating decorations even in header files that are not defined in PellesC standard headers.
To compile this sample you need the header "activscp.h" not included in PellesC, but if you include it you will get so many errors to fill the screen. To solve this problem I wrote an header file "ComDefPelles.h" which simply contains definitions for almost all bloating decorations generated by IDL compiler. You have to include this file just before any MS ole/com header to remove erros.
It is anyway not fully exhaustive, so maybe including some other MS OLE/COM header you will stil get errors. Post the offending header and, if I have time, I'll try to fix it, or, faster, you can do by yourself.
To let you try the code I included the original "activscp.h" from MS SDK. Should this be a big wrong for MS guys I excuse myself and will remove it immediatly. You can still get it downloading SDK.
Last advice the header also defines local variables in the file where it is included with GUID of interfaces that it includes. So if you use the header in more than one module you'll get a 'multiply defined symbol' error from linker. To avoid the redefinition simply prepend
Code: [Select]
#define _NO_SCRIPT_GUIDS
to header inclusion to have only interface prototypes (see file main.h file in the sample).
Hope this will be of any help.

Whole works from Jeff Glatt can be find here http://www.codeproject.com searching for "Jeff Glatt" in search box.
COM articles begins here http://www.codeproject.com/Articles/13601/COM-in-plain-C

PS: I forgot to say that I added a file named 'host' without extension that is simply a copy of "host.vbs" to test the engines enumeration.
« Last Edit: March 30, 2013, 07:42:28 PM by frankie »
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide