Charles Chandler
2005-05-24 19:31:04 UTC
When running a little test app I created based on the code in KB249232
(http://support.microsoft.com/default.aspx?scid=kb;en-us;249232), I keep
encountering an error getting a pointer to the IHTMLDocument2 interface using
the IHTMLWindow2::get_document() function.
On one computer that I've tested this with, the error is consistently
"0x800703e6 Invalid access to memory location."
On another computer, the error is something like "Null reference pointer
<yadda,yadda,yadda>"
Does anybody have any clues they can give me about what's going on here?
Thanks,
CVC
Code snippet follows:
CoInitialize( NULL );
HINSTANCE hInst = ::LoadLibrary( _T("OLEACC.DLL") );
if ( hInst != NULL )
{
if ( HWND != NULL )
{
BSTR ClassName;
this->get_ClassName(&ClassName);
CComBSTR atlbstrClassName(ClassName);
if ( atlbstrClassName == _T("Internet Explorer_Server"))
{
CComPtr<IHTMLDocument2> spDoc;
LRESULT lRes;
UINT nMsg = ::RegisterWindowMessage( _T("WM_HTML_GETOBJECT") );
::SendMessageTimeout( this->hwndGUIObject, nMsg, 0L, 0L,
SMTO_ABORTIFHUNG, 1000, (DWORD*)&lRes );
LPFNOBJECTFROMLRESULT pfObjectFromLresult =
(LPFNOBJECTFROMLRESULT)::GetProcAddress( hInst, _T("ObjectFromLresult") );
if ( pfObjectFromLresult != NULL )
{
HRESULT hr;
hr = (*pfObjectFromLresult)( lRes, IID_IHTMLDocument, 0, (void**)&spDoc
);
if ( SUCCEEDED(hr) )
{
CComPtr<IDispatch> spDisp;
CComQIPtr<IHTMLWindow2> spWin;
spDoc->get_Script( &spDisp );
spWin = spDisp;
hr = spWin->get_document( &spDoc.p );
// Change background color to red
spDoc->put_bgColor( CComVariant("red") );
}
}
} // else document not ready
} // else Internet Explorer is not running
::FreeLibrary( hInst );
} // else Active Accessibility is not installed
CoUninitialize();
(http://support.microsoft.com/default.aspx?scid=kb;en-us;249232), I keep
encountering an error getting a pointer to the IHTMLDocument2 interface using
the IHTMLWindow2::get_document() function.
On one computer that I've tested this with, the error is consistently
"0x800703e6 Invalid access to memory location."
On another computer, the error is something like "Null reference pointer
<yadda,yadda,yadda>"
Does anybody have any clues they can give me about what's going on here?
Thanks,
CVC
Code snippet follows:
CoInitialize( NULL );
HINSTANCE hInst = ::LoadLibrary( _T("OLEACC.DLL") );
if ( hInst != NULL )
{
if ( HWND != NULL )
{
BSTR ClassName;
this->get_ClassName(&ClassName);
CComBSTR atlbstrClassName(ClassName);
if ( atlbstrClassName == _T("Internet Explorer_Server"))
{
CComPtr<IHTMLDocument2> spDoc;
LRESULT lRes;
UINT nMsg = ::RegisterWindowMessage( _T("WM_HTML_GETOBJECT") );
::SendMessageTimeout( this->hwndGUIObject, nMsg, 0L, 0L,
SMTO_ABORTIFHUNG, 1000, (DWORD*)&lRes );
LPFNOBJECTFROMLRESULT pfObjectFromLresult =
(LPFNOBJECTFROMLRESULT)::GetProcAddress( hInst, _T("ObjectFromLresult") );
if ( pfObjectFromLresult != NULL )
{
HRESULT hr;
hr = (*pfObjectFromLresult)( lRes, IID_IHTMLDocument, 0, (void**)&spDoc
);
if ( SUCCEEDED(hr) )
{
CComPtr<IDispatch> spDisp;
CComQIPtr<IHTMLWindow2> spWin;
spDoc->get_Script( &spDisp );
spWin = spDisp;
hr = spWin->get_document( &spDoc.p );
// Change background color to red
spDoc->put_bgColor( CComVariant("red") );
}
}
} // else document not ready
} // else Internet Explorer is not running
::FreeLibrary( hInst );
} // else Active Accessibility is not installed
CoUninitialize();
--
I wish the toaster to be happy, too.
I wish the toaster to be happy, too.