get_body来自 IHTMLDocument2 崩溃程序
get_body from IHTMLDocument2 crash program
程序崩溃
MFCApplication4.exe中0x00000000的首次机会异常: 0xC0000005:访问冲突执行位置0x00000000。
HINSTANCE hInst = ::LoadLibrary(_T("OLEACC.DLL"));
CoInitialize(NULL);
if (hInst != NULL)
{
if (parentWindow != NULL)
{
if (childWindow)
{
CComPtr<IHTMLDocument2> spDoc;
LRESULT lRes;
UINT nMsg = ::RegisterWindowMessage(_T("WM_HTML_GETOBJECT"));
::SendMessageTimeout(childWindow, nMsg, 0L, 0L, SMTO_ABORTIFHUNG, 1000, (DWORD*)&lRes);
LPFNOBJECTFROMLRESULT pfObjectFromLresult = (LPFNOBJECTFROMLRESULT)::GetProcAddress(hInst, LPCSTR("ObjectFromLresult"));
if (pfObjectFromLresult != NULL)
{
HRESULT hr;
hr = (*pfObjectFromLresult)(lRes, IID_IHTMLDocument, 0, (void**)&spDoc);
if (SUCCEEDED(hr))
{
CComPtr<IHTMLElement> pHTMLElement;
hr = spDoc->get_body(&pHTMLElement);// <-this line breaks the program
//BSTR bstrText;
//pHTMLElement->get_innerText(&bstrText);
//edit1->SetWindowTextW(bstrText);
}
}
}
}
::FreeLibrary(hInst);
}
CoUninitialize();
我从 MFC 对话框应用程序的按钮执行此代码只是为了测试代码 这是汽车
- &pHTMLElement 0x00ddeb10 0x00000000
ATL::CComPtr * - 人力资源S_OK 结果
- pHTMLElement 0x00000000 ATL::CComPtr
- spDoc 0x03303f7c {...} ATL::CComPtr
- this 0x00ddfbd8 {hWnd=0x001905b6 {unused=??? }} CMFCApplication4Dlg *
我不知道是什么错误
在这一行:
hr = (*pfObjectFromLresult)(lRes, IID_IHTMLDocument, 0, (void**)&spDoc);
您正在请求一个IHTMLDocument
,但您正在为其提供指向IHTMLDocument2
的指针。
相关文章:
- 提升 ASIO Async_receive崩溃程序
- 类指针方法崩溃程序
- get_body来自 IHTMLDocument2 崩溃程序
- 是否有可能存在不会崩溃程序的内存问题
- 调试运行时出现奇怪的崩溃程序(Eclipse C++)
- 儿童对话框 - setWindowTexta或sendmessagea崩溃程序-MFC
- 顶点阵列GLFW崩溃C 程序
- 将值分配给Float数据类型崩溃程序
- OpenCV-将变量添加到类成员崩溃程序
- boost::interprocess::managed_shared_memory 崩溃程序
- 将枚举值分配给整数崩溃程序
- SDL 1.2 -> SDL 2.0(崩溃程序)
- 空析构函数崩溃程序:C++
- 冒泡排序崩溃程序c++
- Ofstream关闭崩溃程序
- 删除字符* 崩溃程序
- c++矢量擦除崩溃程序
- Lua_getglobal崩溃程序
- 通过Copy Constructor创建的e2打印崩溃程序
- RNG崩溃c++程序