为什么我用->Navigate("URL",NULL,NULL,NULL)时会出RUNTIME错误?(急,在线等,马上结分)
我在做一个屏蔽网站的东西,把需要屏蔽的站转成空白页
我的代码:
void enum_pages(){
int judge = 0;
CoInitialize(NULL); //必须要这句初始化
SHDocVw::IShellWindowsPtr m_spSHWinds = NULL;
if (m_spSHWinds == NULL){
if (m_spSHWinds.CreateInstance(__uuidof(SHDocVw::ShellWindows)) == S_OK){
VARIANT id, index;
CComPtr<IDispatch> spDispatch;
CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> pDoc2;
CComPtr<IHTMLElement> pElement;
CComPtr<IHTMLElementCollection> pElementCol;
CComPtr<IHTMLFormElement> pFormElement;
CComPtr<IHTMLInputTextElement> pInputElement;
// TODO: Add your control notification handler code here
// TODO: Add extra initialization here
//(sizeof(Content)-50)
if ('\0' == Content[(sizeof(Content)-50)]){
if (m_spSHWinds){
int n = m_spSHWinds->GetCount();
for (int i = 0; i < n; i++){
_variant_t v = (long)i;
IDispatchPtr spDisp = m_spSHWinds->Item(v);
SHDocVw::IWebBrowser2Ptr spBrowser(spDisp); //生成一个IE窗口的智能指针
if (spBrowser){
if (strstr("需要屏蔽的URL",_bstr_t(spBrowser->GetLocationName())))
{
spBrowser->Navigate("about:blank",NULL, NULL, NULL, NULL );
=============================================
编译通过
运行到spBrowser->Navigate("about:blank",NULL, NULL, NULL, NULL );
时出错
错误信息如下:
---------------------------
Microsoft Visual C++ Runtime Library
---------------------------
Runtime Error!
Program: D:\test\Release\test.exe
abnormal program termination
---------------------------
确定
---------------------------