win32com and MSHTML

Peter Parente parente at cs.unc.edu
Sat Mar 29 06:48:59 CET 2003


I'm having a problem using the win32com library with the MSHTML library for
Windows. Here's my procedure.

I obtain a COM object for the IHtmlWindow2 interface for an instance of
Internet Explorer. I then call DispatchWithEvents on its 'document' property
to get the COM object for the IHtmlDocument2 interface. I also provide
DispatchWithEvents with a class to receive the event callbacks. Each time
the browser navigates off of its current page, I call DispatchWithEvents
again to get the new document object and watch its events. All of this works
fine.

After doing this about 5-10 times, though, I notice that my IE window begins
to 'lag' considerably. Simple operations like scrolling and selecting text
are very sluggish whereas they used to be quick.

It seems like the old document objects are not being released properly. Each
time I obtain a new IHtmlDocument2 object, I delete the previously held one
so that it can be released by IE. However, it seems like they're piling up.
The documentation for the win32com package says that using
DispatchWithEvents should take care of the circular reference problem, but
it doesn't seem to be doing so in this case.

Any help in solving this problem would be greatly appreciated.

Thanks,
Pete






More information about the Python-list mailing list