I have a C++ library (Win32) that fills some fields in a web page that I would like to use from .NET (an IE toolbar) but I can’t figure out how to expose the method through COM. I already know I should add it to the interface in the .idl file like this:
interface IPlugin : IDispatch{
#include <mshtml.h>
HRESULT FillFields(IHTMLDocument2* pDocument, BSTR value1, BSTR value2);
};
but the #include of mshtml.h gives me the following errors:
error MIDL2003: redefinition : _LARGE_INTEGER
error MIDL2003: redefinition : _ULARGE_INTEGER
error MIDL2003: redefinition : INT
error MIDL2003: redefinition : Int64ShllMod32
Is there any way I can pass the IHTMLDocument object from C# to C++ and modify it’s content in C++ or is COM supposed to be used only with types meant for Automation, like BSTR?
Thanks
You would use
#importto get the IDL definition ofIHTMLDocument2into scope in MIDL.The MIDL compiler will generate the
#includefor you. Explicit#includein MIDL files is useful only in a very narrow set of corner cases.