[python-win32] IE DOM ptr as input to DLL function - Doing this right?
jef at jefallbright.net
Fri Jun 29 21:34:58 CEST 2007
I'm a newbie to Win32 COM and am unsure whether my current problem
lies in what I'm doing or possibly in some quirk of the DLL I'm trying
to use from Python.
I have a snippet of C++ that I want to implement in Python:
At first, I tried using win32com.Client.Dispatch to create a COM
object for both my DLL and for the IE browser, and that worked well up
to the point where I tried to use the ie.Document object as input to
Analyze where it expects the pVoid. Got "argument is not a COM
I learned from Thomas Heller via this post:
that win32com doesn't known about comtype objects, so I tried the type
conversion function given there but got an error complaining about
unable to find the query interface.
I switched tracks at this point and implemented both COM objects using comtypes:
>>> from comtypes.client import *
>>> o = CreateObject("MyDLL.MyAnalyzer")
>>> ie = CreateObject("InternetExplorer.Application")
>>> doc = ie.Document
<POINTER(DispHTMLDocument) object 163a260>
# This seems as expected, right?
>>> o.Analyze(doc, 10)
Here, it seems to accept my input and goes away for a while, and then
barfs with WindowsError: exception code 0xe06d7363 (the DLL threw an
>From the makepy file, here is the DLL function template:
def Analyze(self, pHtmlDoc=defaultNamedNotOptArg,
return self._oleobj_.InvokeTypes(3, LCID, 1, (24, 0), ((9, 0),
My question is whether or not it appears I'm passing the DOM ptr
properly. I don't have the source for the DLL but it works well with
an executable demo.
Thanks in advance for any advice.
More information about the Python-win32