0

IWebExplorer2::Navigate(..) (or Navigate2) is failing to navigate some urls. Like while navigating following 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);}

Please could any one tell me what I am missing?

Thanks in advance.

Thomas Fenzl
  • 4,342
  • 1
  • 17
  • 25
Sajad Karim
  • 321
  • 3
  • 18

1 Answers1

0

Following Navigate2 method URL Type is Variant, and for Navigate method url type is BSTR; If you have ATL support you can use CComVariant with Navigate2, or CComBSTR with Navigate;

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;
}
volody
  • 6,946
  • 3
  • 42
  • 54