我正在尝试将Web浏览器控件嵌入到CE 6应用程序的窗口中。我可以创建Web浏览器控件但无法加载URL。到目前为止的代码是:
CoInitializeEx(NULL, COINIT_MULTITHREADED);
IWebBrowser2 * pBrowser = NULL;
HRESULT hr;
hr = CoCreateInstance (CLSID_WebBrowser, NULL, CLSCTX_INPROC_SERVER, IID_IWebBrowser2, (void **) &pBrowser);
if (SUCCEEDED (hr))
{
pBrowser->put_Visible ((VARIANT_BOOL) true);
VARIANT vEmpty;
VariantInit(&vEpty);
BSTR bstrURL = SysAllocString(L"http://microsoft.com");
hr = pBrowser->Navigate(bstrURL, &vEmpty, &vEmpty, &vEmpty, &vEmpty);
// ** At this point, hr = E_FAIL
}
else
{
MessageBox(_T("Could not create browser window"), _T("Error"), MB_OK);
}
为什么拨打Navigate()
的电话会回复E_FAIL
?