Evidence of pythoncom bug?

Bill Bell bill-bell at bill-bell.hamilton.on.ca
Thu Sep 6 15:55:26 EDT 2001


In the Delphi world, many people use Per Lindsø Larsen's 
"UI_Less" code as a guide to how to drive MSHTML. I've just rebuilt 
his code on my machine with two additional lines that display 
certain GUIDs that it uses, as strings.

---- code starts ----
  CoCreateInstance(CLASS_HTMLDocument, nil, 
CLSCTX_INPROC_SERVER, IID_IHTMLDocument2, Doc);
  Unit1.Form1.Memo1.Lines.Add ( GUIDToString ( 
CLASS_HTMLDocument ) );
  Unit1.Form1.Memo1.Lines.Add ( GUIDToString ( 
IID_IHTMLDocument2 ) );
---- code ends ----

The example executes normally and produces the following lines 
that include the GUIDs.

---- output starts ----
Memo1
{25336920-03F9-11CF-8FD0-00AA00686F13}
{332C4425-26CB-11D0-B483-00C04FD90119}
http://www.microsoft.com/isapi/gomscom.asp?target=/
http://www.microsoft.com/isapi/gomscom.asp?target=/catalog/defa
ult.asp?subid=22
http://www.microsoft.com/isapi/gomscom.asp?target=/support/ ...
---- output ends ----

In the far-less-attractive-but-nontheless-dominant MSVC world I 
recently built the MS 'walkall' example (on which Larsen's example 
is based) and added a few lines to display the GUIDs sent to 
CoCreateInstance, as before.

---- code starts ----
if (FAILED(hr = CoCreateInstance( CLSID_HTMLDocument, NULL, 
CLSCTX_INPROC_SERVER, IID_IHTMLDocument2, 
(LPVOID*)&g_pApp -> m_pMSHTML ))){goto Error;}

TCHAR szBuff[40];

IIDAsChar ( IID_IHTMLDocument2, szBuff );
cout << "IID_IHTMLDocument2: " << szBuff << endl;


IIDAsChar ( CLSID_HTMLDocument, szBuff );
cout << "CLSID_HTMLDocument: " << szBuff << endl;
---- code ends ----

wherein IIDAsChar is defined as,

---- code starts ----
ivoid IIDAsChar ( IID iid, TCHAR * szBuff )
{
	wsprintf(szBuff, "%08X-%04X-%04X-%02X%02X-
%02X%02X%02X%02X%02X%02X", 
		iid.Data1, iid.Data2, iid.Data3, 
		iid.Data4 [ 0 ], iid.Data4 [ 1 ], iid.Data4 [ 2 ], iid.Data4 [ 3 ], 
		iid.Data4 [ 4 ], iid.Data4 [ 5 ], iid.Data4 [ 6 ], iid.Data4 [ 7 ] 
);
}
---- code ends ----

OK, I know, this must repel all real C++ types. Nonetheless, 
walkall performs normally and outputs the following values for the 
GUIDs.

---- output starts ----
IID_IHTMLDocument2: 332C4425-26CB-11D0-B483-00C04FD90119
CLSID_HTMLDocument: 25336920-03F9-11CF-8FD0-
00AA00686F13
Mozilla/4.0 (compatible; MSIE 5.5; Windows 95)
---- output ends ----

Now when I attempt to do the same thing in PythonWin,

---- code starts ----
MSHTMLInterface = CoCreateInstance ( '{25336920-03F9-11CF-
8FD0-00AA00686F13}', None, pythoncom . 
CLSCTX_INPROC_SERVER,  '{332C4425-26CB-11D0-B483-
00C04FD90119}' )
---- code ends ----

the result is,

---- output starts ----
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
TypeError: There is no interface object registered that supports this 
IID
---- output ends ----

What do you think?

Bill

Bill Bell, Software Developer




More information about the Python-list mailing list