早上好,
当我调用“webBrowser = GetIWebBrowser(this->_hwnd, errorMsg);”时,没问题。我的问题是“webBrowser->get_Document(&ppDisp)”。它返回一个不同于 S_OK 的值。但我不知道为什么。使用 GetLastError 不返回任何内容。而且我不知道如何使用结构 IErrorInfo。我必须使用 IErrorInfo 吗?因为“::GetErrorInfo(0, &errorInfo);”将 NULL 放入 errorInfo :(
奇怪的是我在一些带有“windows update 1909”的计算机和一些用户上遇到了问题。但是在其他电脑上,没有问题。我不知道为什么,我正在寻找原因,但我没有找到原因。
char errorMsg[L_TEXT + 1];
IDispatch * ppDisp;
IWebBrowser2 * webBrowser;
bool ok = true;
HRESULT res = S_FALSE;;
memset(errorMsg, 0x00, sizeof(errorMsg));
try {
webBrowser = GetIWebBrowser(this->_hwnd, errorMsg);
if (webBrowser)
{
res = webBrowser->get_Document(&ppDisp);
if (res != S_OK)
{
std::stringstream errorDetails;
DWORD lastError = GetLastError();
char lastError_str[200];
getSystemError(lastError, sizeof(lastError_str), lastError_str);
if (strcmp(lastError_str, ""))
errorDetails << "webBrowser->get_Document(&ppDisp) returns " << res << " with get last error = " << lastError_str;
else
{
CComPtr<IErrorInfo> errorInfo;
::GetErrorInfo(0, &errorInfo);
if (errorInfo != NULL)
{
CComBSTR bstrMsg;
errorInfo->GetDescription(&bstrMsg);
errorDetails << "Without GetLastError : webBrowser->get_Document(&ppDisp) returns " << res << " with get last error = " << bstrMsg.m_str;
}
}
GEMLOG(ErrorLevel, "bool IntegratedBrowser::SetWebpage( CWebPage& webPage)", errorDetails.str().c_str())
}
}
...
你能帮我吗?谢谢