Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error using MSHTML objects
#1
When I use the following code

Htm el = htm ( "some parameters here...getting a <TABLE> element")
MSHTML.IHTMLTable t = +el
mes t.rows.length

everything works. But if I use a pointer variable...

Htm el = htm ( "some parameters here...getting a <TABLE> element")
Htm* elp = &el
MSHTML.IHTMLTable* t = +elp
mes t.rows.length

...I get the error message "invalid interface pointer. Use _create or other function to create or get object".
Why?
#2
In first case, MSHTML.IHTMLTable t = +el queries IHTMLTable interface from object of IHTMLElement2 type, and it succeeds.

In second case, t just receives pointer to pointer to IHTMLElement2 interface. That is, type mismatch. When it tries to call rows, it actually calls some function of IHTMLElement2 interface that is at the same offset in vtbl. This is wrong way to cast interface pointers. In many cases it would give exception, or QM would crash.


Forum Jump:


Users browsing this thread: 1 Guest(s)