_hwnd, errorMsg);", no problem. My problem is with "webBrowser->get_Document(&ppDisp)". I" /> _hwnd, errorMsg);", no problem. My problem is with "webBrowser->get_Document(&ppDisp)". I" /> _hwnd, errorMsg);", no problem. My problem is with "webBrowser->get_Document(&ppDisp)". I"/>

function get_Document (ExDisp.h -) - how to get error message : IErrorInfo?

76 views Asked by At

Good morning,

When I call "webBrowser = GetIWebBrowser(this->_hwnd, errorMsg);", no problem. My problem is with "webBrowser->get_Document(&ppDisp)". It returns a value different to S_OK. But I don't know why. Using GetLastError returns nothing. And I don't know how to use the structure IErrorInfo. Must I use IErrorInfo ? Because "::GetErrorInfo(0, &errorInfo);" puts NULL in errorInfo :(

What is strange is I've the problem on some computers with the "windows update 1909" and some users. But on others computers, there are no problem. I don't know why and I'm looking for why but I don't find the reason.

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())
        }
    }
    ...

Can you help me please ? Thanks

0

There are 0 answers