IWebExplorer2::Navigate(..) (or Navigate2)
无法导航某些url。就像导航下面的url: *https://www.facebook.com/dialog/oauth/?api_key=<MyKey>&redirect_uri=<MyUri>&state=NONE* , I am getting the error **Error reading characters of string** in **DISPID_NAVIGATEERROR**
。
......
wchar_t ws[MAX_PATH];
TCharToWide(url,ws,MAX_PATH);
VARIANT v; v.vt=VT_I4; v.lVal=0; //v.lVal=navNoHistory;
ibrowser->Navigate(ws,&v,NULL,NULL,NULL);
......
void TCharToWide(const wchar_t *src,wchar_t *dst,int dst_size_in_wchars){wcscpy(dst,src);}
谁能告诉我我错过了什么?
下面的Navigate2方法URL类型为Variant,对于Navigate2方法URL类型为BSTR;如果你有ATL支持,你可以使用CComVariant
与Navigate2,或CComBSTR
与导航;
NavToURL( L"www.google.com", FALSE);
BOOL NavToURL(const wchar_t* url, BOOL isnewtab){
CComVariant vEmpty;
CComVariant vURL(url);
CComVariant flag=isnewtab ? 0x0800 : vEmpty;
ibrowser->Navigate2(&vURL, &flag, &vEmpty, &vEmpty, &vEmpty);
return TRUE;
}