According to Internet Explorer_Server get IWebBrowser2 window , call Navigate2 failure

Category: VC/MFC -> HTML/XML Author: lfy91 Date: 2006-12-23 16:10:00
 
lfy91
2006-12-23 16:10:00
Function code is as follows , hWnd parameter passed for Internet   result Explorer_Server window handle
function calls are always executed FAIL, who pointed out the mistake Daren Thank
void  ? MyNavigate2 (HWND   hWnd , char   * url)  
{
CoInitialize (  NULL  );

HINSTANCE   hInst   =   LoadLibrary (_T (" OLEACC.DLL " ));
IWebBrowser2 *   pWebBrowser2 = NULL;!!
if (hInst = NULL)
{
if (hWnd = NULL)
{
LRESULT   lRes;
UINT   nMsg   =   :: RegisterWindowMessage (_T (" WM_HTML_GETOBJECT "));
:: SendMessageTimeout (hWnd, nMsg, 0L, 0L, SMTO_ABORTIFHUNG,   1000 ,   (DWORD *) & lRes  );
LPFNOBJECTFROMLRESULT   pfObjectFromLresult   =   (LPFNOBJECTFROMLRESULT) :: GetProcAddress (hInst,   _T (" ObjectFromLresult ")  );
if (pfObjectFromLresult = NULL!)
{
HRESULT   hr;
CComPtr < IHTMLDocument2 > spDoc;
hr = pfObjectFromLresult (lRes, IID_IHTMLDocument2,0, (void **) & spDoc);
if (SUCCEEDED (hr))
{
CComPtr < IHTMLWindow2 > spWnd2;
CComPtr < IServiceProvider > spServiceProv;

hr = spDoc- > get_parentWindow   ((IHTMLWindow2 **) & spWnd2);
if (SUCCEEDED (hr))
{
hr = spWnd2- > QueryInterface   (IID_IServiceProvider, (void **) & spServiceProv);
if (SUCCEEDED (hr))
{
hr   =   spServiceProv- > QueryService (SID_SWebBrowserApp, IID_IWebBrowser2, (void **) & pWebBrowser2);

CComVariant   d = " ";

hr = pWebBrowser2- > Navigate2 (& d, NULL, NULL, NULL, NULL);
Sleep (10000);
if (SUCCEEDED (hr))
{
MessageBox (NULL, " SUCCEEDED ", " Navigate2 ", MB_ICONSTOP);
}
else
MessageBox (NULL, " fail ", " Navigate2 ", MB_ICONSTOP);
// pWebBrowser2- > Navigate2 ((VARIANT   *) url, & t, & v, & p, & h);
}
}
}

}
}
:: FreeLibrary (hInst );
}  
CoUninitialize ();
}
lfj200821
2006-12-23 16:28:12
error code?
LINJIANMIN
2006-12-23 16:31:26
I also encountered the same problems as you , I SNIFF data found HEADER changed after the data is sent properly , but I get on with document.referrer in less than a referrer 's website value. Really depressed ! ! !
ottzs03
2006-12-23 16:39:23
In order to facilitate the page to see the code , re- issued under the code
void   MyNavigate2 (HWND   hWnd, char   * url)  
{
CoInitialize (  NULL  );

HINSTANCE   hInst   =   LoadLibrary (_T (" OLEACC.DLL "));
IWebBrowser2 *   pWebBrowser2 = NULL;
if (hInst !! = NULL)
{
if (hWnd = NULL)
{
LRESULT   lRes;
UINT   nMsg   =   :: RegisterWindowMessage (_T ( " WM_HTML_GETOBJECT "));
:: SendMessageTimeout (hWnd, nMsg, 0L, 0L, SMTO_ABORTIFHUNG,   1000,   (DWORD *) & lRes  );
LPFNOBJECTFROMLRESULT   pfObjectFromLresult   =   (LPFNOBJECTFROMLRESULT) :: GetProcAddress (hInst,   _T (" ObjectFromLresult ")  );
if (! pfObjectFromLresult = NULL)
{
HRESULT   hr;
CComPtr < IHTMLDocument2 > spDoc;
hr = pfObjectFromLresult (lRes, IID_IHTMLDocument2,0, (void **) & spDoc);
if (SUCCEEDED (hr))
{
CComPtr < IHTMLWindow2 > spWnd2;
CComPtr < IServiceProvider > spServiceProv;

hr = spDoc- > get_parentWindow   ((IHTMLWindow2 **) & spWnd2);
if (SUCCEEDED (hr))
{
hr = spWnd2- > QueryInterface   (IID_IServiceProvider, (void **) & spServiceProv);
if (SUCCEEDED (hr))
{
hr   =   spServiceProv- > QueryService (SID_SWebBrowserApp, IID_IWebBrowser2, (void **) & pWebBrowser2);

CComVariant   d = " ";

hr = pWebBrowser2- > Navigate2 (& d, NULL, NULL, NULL, NULL);
Sleep (10000);
if (SUCCEEDED (hr))
{
MessageBox (NULL, " SUCCEEDED ", " Navigate2 ", MB_ICONSTOP);
}
else
MessageBox (NULL, " fail ", " Navigate2 " , MB_ICONSTOP);
// pWebBrowser2- > Navigate2 ((VARIANT   *) url, & t, & v, & p, & h);
}
}
}

}
}
:: FreeLibrary (hInst);
}  
CoUninitialize ();
}
adae13
2006-12-23 16:42:03
they have to solve this problem, by the way , Navigate2 visit the website how to specify referer? modify lpheaders always unsuccessful
wuwu0059
2006-12-23 16:59:37
Hello , the problem is how to solve I call Navigate2 is invalid