I switched over to Delphi from Visual Basic to see if it helped. As it turns out, one of the problems (crashing when having a focused control) went away with this change, but the 216 stuck around.

I finally found the answer, though! It turns out that the help files may have been lying. I browsed around Usenet for a while and found some advice that said to use OleInitialize(nil) and OleUninitialize if I'm using the webbrowser. So... I did. But it still didn't work.

In the meantime, I enjoyed the following sidetrack: http://tinyurl.com/djc6

The webbrowser component apparently has a nasty memory leak. So I fixed that, but it still didn't work. I also bumped into this post, poor soul. That's exactly the problem I was experiencing. The unlucky person never got an answer.

So anyway, I finally found this post. PRAISE THE LORD! The help files said to call OleUninitialize if OleInitialize gave back S_OK or S_FALSE "to close the library gracefully." I don't know about you, but I don't consider a 216 error graceful! So I only called OleUninitialize if I get S_OK for the first func. It works. I don't know whether it leaks memory but to be honest, I don't give a flying four letter word.

And now my thing works.

Here's some advice for anyone who'll be risking using a webbrowser in an OCX -- consider killing yourself instead. It'll give you less stress in the long run. I'd like to say thanks to Xorcist, who gave a few hints [which didn't pan out, unfortunately] while I was still fiddling away with the VB project. Also, thanks to the particular person who posted that solution in Usenet. Finally, a big swear word or three to anybody who designed ActiveX/Ole in the first place for making it such an over-engineered pain in the butt.