The SDK version I used was from 06/2001 - include files zipped are 3.8 MB. If you have difficulties to download that 2.5 GB package...
Incredible, some warnings but it compiles with VC Express 2010 on WinXP SP3 :t
Minor problem - on exit it crashes (for google.com, but not for local files) here:
40324587 BE 05400080 mov esi, 80004005 << google for CLR error 80004005
4032458C 74 2F je short 403245BD
4032458E 8B08 mov ecx, [eax]
40324590 8D55 14 lea edx, [ebp+14]
40324593 52 push edx
40324594 68 84293340 push 40332984
40324599 50 push eax
4032459A FF11 call near [ecx] <<<<< ecx is ddddddddhActually, I am trying to translate a Windows CE example that is suspiciously simple, and it fails when I try to query for the client site:
otf CoCreateI: OK
otf Qu_OleObj: OK
otf MiscFlags: OK
otf Qu_Client: Interface not supportedThe MSDN .cpp code is included in the attachment. Apologies that this is MasmBasic ;-)
.code
CLSID_
WebBrowser GuidFromString(8856F961-340A-11D0-A96B-00C04FD705A2)
; ExDisp.hIID_
IWebBrowser2 GuidFromString(D30C1661-CDAF-11D0-8A3E-00C04FC9E26E)
; OleIdl.hIID_IUnknown
GuidFromString(00000000-0000-0000-C000-000000000046)
IID_IOleObject
GuidFromString(00000112-0000-0000-C000-000000000046)
; MSDNIID_IOleClientSite
GuidFromString(00000118-0000-0000-C000-000000000046)
OleTestFail MACRO arg
ifnb <arg> pushad
.if eax
Print "otf &arg&: ", Tb$,
Utf8$(
MsgTable$(eax, "kernel32"))
.else
PrintLine cStyle$("otf &arg&: \tOK")
.endif
popad
endif
.if esp!=jesp
mov edx, jesp
sub edx, esp
deb 1, "CoInv stack &arg&", edx
.endif
cmp eax, S_OK
jne OleErr
ENDM
CreateBrowserObject proc
; based on MSDN Windows CE exampleLOCAL pUnk:IUnknown, pObject:IOleObject, pClientSite:IOleClientSite, cboRc:RECT, dwFlags
ClearLocalVariables uses esi edi mov jesp, esp
; check stack to see if # of params correct
lea
edi, pUnk
; ptr to unknown interface
lea
esi, pObject
; ptr to OLE object
.if !pWB2
; global pInterface WebBrowser2 ; hr = CoCreateInstance(CLSID_WebBrowser, NULL, CLSCTX_INPROC, IID_IUnknown, (LPVOID *)(&pUnk));
invoke CoCreateInstance, offset CLSID_
WebBrowser, NULL, CLSCTX_INPROC, offset IID_
IWebBrowser2,
edi OleTestFail CoCreateI
m2m pWB2, [edi]
; hr = pUnk->QueryInterface(IID_IOleObject, (LPVOID *)(&pObject));
CoInvoke [
edi], IUnknown.
QueryInterface, offset IID_IOleObject,
esi OleTestFail Qu_OleObj
; // Check if Shdocvw requires a client site to be created first.
; hr = pObject->GetMiscStatus(DVASPECT_CONTENT, &dwFlags); CoInvoke [
esi], IOleObject.
GetMiscStatus, DVASPECT_CONTENT, addr dwFlags
OleTestFail MiscFlags
and dwFlags, 20000h
; OLEMISC_SETCLIENTSITEFIRST ->MSDN:
OLEMISC enumeration .if Zero?
deb 1, "No client site required", dwFlags
; never seen .else
; IOleClientSite *pClientSite;
; hr = QueryInterface(IID_IOleClientSite, (LPVOID *)(&pClientSite));
lea
ecx, pClientSite
; IOleObject::IOleClientSite CoInvoke [
esi], IUnknown.
QueryInterface, offset IID_IOleClientSite,
ecx ;
---------- fails here: ------------- OleTestFail Qu_Client
; hr = QueryInterface(IID_IOleClientSite, (LPVOID *)(&pClientSite)); lea
ecx, pClientSite
; hr = pObject->SetClientSite(pClientSite);
CoInvoke [
esi], IOleObject.
SetClientSite, ecx OleTestFail SetClientSite
; pClientSite->Release();
lea
ecx, pClientSite
CoInvoke [
ecx], IOleObject.xUnknown.
Release OleTestFail Release
.endif
.endif
OleErr:
PopUses
ret
CreateBrowserObject endp
P.S.: I smuggled in a new MACRO called GuidsEqual:
; expected: EQUAL, DIFFER, EQUAL, DIFFER
.if GuidsEqual(offset IID_IUnknown, IID_IUnknown)
nop ; offset, direct
.endif
.if GuidsEqual(IID_IUnknown, IID_IOleObject)
nop ; direct
.endif
mov eax, offset IID_IOleObject
.if GuidsEqual(eax, IID_IOleObject)
nop ; one offset in reg32
.endif
invoke CmpGUIDS, addr IID_IOleObject, addr IID_IUnknown
Works fine except that for JWasm they are all equal :(