0

Why is the following doc2 different from doc22?

IHTMLDocument2 doc2 = (pDisp as IWebBrowser2).Document as IHTMLDocument2;
IHTMLDocument2 doc22 = doc2.body.document as IHTMLDocument2;
bool isequal = Marshal.GetIUnknownForObject(doc2) == Marshal.GetIUnknownForObject(doc22);
//Here, isequal is false. Why?
Heinrich Ulbricht
  • 10,064
  • 4
  • 54
  • 85
Calvin Kwok
  • 161
  • 1
  • 9

1 Answers1

0

For me the most likely explanation is that different wrapper objects are created for the same thing. Who knows how MSHTML manages this internally. As long as ((pDisp as IWebBrowser2).Document as IHTMLDocument3).documentElement as IUnknown == (((pDisp as IWebBrowser2).Document as IHTMLDocument2).body.document as IHTMLDocument3).documentElement as IUnknown the world is in order ;)

Heinrich Ulbricht
  • 10,064
  • 4
  • 54
  • 85