I'm trying to access the IHTMLDocument6.documentMode
property from my IE BHO, but that interface is not defined in any of the mshtml assemblies I can find on my machine.
I've tried hacking together an interface definition for the interface:
[Guid("30510417-98b5-11cf-bb82-00aa00bdce0b")]
[TypeLibType(4160)]
public interface IHTMLDocument6
{
[DispId(1104)]
float documentMode { get; }
}
I can successfully cast the document object to this interface, but I do not get a value that makes sense for the do开发者_如何学GocumentMode
property.
Where can I find the version of mshtml that includes the IHTMLDocument6
interface, or a correct version of the interface definition to use? Or is there some other way I should be doing this?
Thanks.
You can always use latebinding and do a Type.Invokemember
http://msdn.microsoft.com/en-us/library/66btctbe.aspx
You can get Headers and Libs for IE9 from here. If that link becomes broken, I got it from here.
You can get interop examples from pinvoke.net. It seems pretty thin on MSHTML, but you can add to it once you get it figured out.
This is the correct code to use
[Guid("30510417-98b5-11cf-bb82-00aa00bdce0b")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
public interface IHTMLDocument6
{
[DispId(1104)]
object documentMode { get; }
}
A VARIANT
is an object
in P/Invoke. The above also uses IDispatch which minimizes fuss.
精彩评论