0

I've been told that every COM method callable from C++ code (take for instance IHTMLDocument2::write) has an equivalent C declaration, usable from C code...

How do I find it?

Thanks in advance!

2 Answers 2

1

This particular interface is documented as being provided by <mshtml.h>. Now, as it happens the second and third line of that file are:

// Include the full header file that works for C
#include "mshtmlc.h"

Looking into that file, we find the declaration

    /* [id][vararg] */ HRESULT ( STDMETHODCALLTYPE *write )( 
        IHTMLDocument2 * This,
        /* [in] */ __RPC__in SAFEARRAY * psarray);

Note that this is actually a pointer to the IHTMLDocument2::write method.

Sometimes the C declaration is the same header; sometimes the declaration isn't publicly available. But the COM standard is an ABI (a binary interface) designed such that you can always write a C declaration. Could be painful though.

Sign up to request clarification or add additional context in comments.

1 Comment

Looks painful indeed ;-) Thank you!
1

Method calls of the type R Interface::Foo(T1, ..., Tn) simply translate to R Foo(Interface*, T1, ..., Tn).

They are available when compiling as C, i.e. __cplusplus not defined, or CINTERFACE is defined.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.