妖哥来看,关于webbrowser的问题
1. 照妖哥网站文档www.ccrun.com/article.asp?i=169&d=st0528中,“如何改变cppWebBrowser的HTML内容”, 我执行后最后部分:
delete psi;delete stream;
Access violation at adress ... in module 'borlndmm.dat'. Read of address 00000000.
BOOL __stdcall CrnSetHtmlContent(IHTMLDocument2 *spDoc, LPCTSTR lpText){ BOOL bResult(FALSE); if (NULL == spDoc) return bResult; IStream *pStream; IPersistStreamInit *psi; int nLen = _tcslen(lpText); HGLOBAL hHTMLText = ::GlobalAlloc(GPTR, nLen * sizeof(TCHAR) + 1); if (NULL == hHTMLText) return bResult; ::CopyMemory(hHTMLText, lpText, nLen * sizeof(TCHAR)); HRESULT hr = ::CreateStreamOnHGlobal(hHTMLText, true, &pStream); if (SUCCEEDED(hr)) { hr = spDoc->QueryInterface(IID_IPersistStreamInit, (void **)&psi); if (SUCCEEDED(hr)) { hr = psi->Load(pStream); bResult = SUCCEEDED(hr); psi->Release(); } pStream->Release(); } ::GlobalFree(hHTMLText); return bResult;}