Partager via


interface ICoreWebView2ExperimentalEnvironment11

Note

This reference is no longer being maintained. For the latest API reference, see WebView2 API Reference.

Note

This an experimental API that is shipped with our prerelease SDK. See WebView2 release notes.

interface ICoreWebView2ExperimentalEnvironment11
  : public IUnknown

This is the ICoreWebView2ExperimentalEnvironment11 interface.

Summary

Members Descriptions
GetProcessInfosWithDetails Gets a snapshot collection of ProcessInfos corresponding to all currently running processes associated with this ICoreWebView2Environment except for crashpad process.

Applies to

Product Introduced
WebView2 Win32 N/A
WebView2 Win32 Prerelease 1.0.1988

Members

GetProcessInfosWithDetails

Gets a snapshot collection of ProcessInfos corresponding to all currently running processes associated with this ICoreWebView2Environment except for crashpad process.

public HRESULT GetProcessInfosWithDetails(ICoreWebView2ExperimentalGetProcessInfosWithDetailsCompletedHandler * handler)

This provides the same list of ProcessInfos as what's provided in GetProcessInfos, but additionally provides a list of associated FrameInfos which are actively running (showing UI elements) in the renderer process. See AssociatedFrameInfos for more information.

        CHECK_FAILURE(environmentExperimental11->GetProcessInfosWithDetails(
            Callback<ICoreWebView2ExperimentalGetProcessInfosWithDetailsCompletedHandler>(
                [this](HRESULT error, ICoreWebView2ProcessInfoCollection* processCollection)
                    -> HRESULT
                {
                    UINT32 processCount = 0;
                    UINT32 rendererProcessCount = 0;
                    CHECK_FAILURE(processCollection->get_Count(&processCount));
                    std::wstring result;
                    std::wstring otherProcessResult;
                    for (UINT32 i = 0; i < processCount; i++)
                    {
                        Microsoft::WRL::ComPtr<ICoreWebView2ProcessInfo> processInfo;
                        CHECK_FAILURE(processCollection->GetValueAtIndex(i, &processInfo));
                        COREWEBVIEW2_PROCESS_KIND kind;
                        CHECK_FAILURE(processInfo->get_Kind(&kind));
                        INT32 processId = 0;
                        CHECK_FAILURE(processInfo->get_ProcessId(&processId));
                        if (kind == COREWEBVIEW2_PROCESS_KIND_RENDERER)
                        {
                            std::wstring rendererProcessResult;
                            wil::com_ptr<ICoreWebView2ExperimentalProcessInfo>
                                processInfoExperimental;
                            CHECK_FAILURE(processInfo->QueryInterface(
                                IID_PPV_ARGS(&processInfoExperimental)));
                            wil::com_ptr<ICoreWebView2FrameInfoCollection> frameInfoCollection;
                            CHECK_FAILURE(processInfoExperimental->get_AssociatedFrameInfos(
                                &frameInfoCollection));
                            wil::com_ptr<ICoreWebView2FrameInfoCollectionIterator> iterator;
                            CHECK_FAILURE(frameInfoCollection->GetIterator(&iterator));
                            BOOL hasCurrent = FALSE;
                            UINT32 frameInfoCount = 0;
                            while (SUCCEEDED(iterator->get_HasCurrent(&hasCurrent)) &&
                                   hasCurrent)
                            {
                                wil::com_ptr<ICoreWebView2FrameInfo> frameInfo;
                                CHECK_FAILURE(iterator->GetCurrent(&frameInfo));

                                AppendFrameInfo(frameInfo, rendererProcessResult);
                                AppendAncestorFrameInfo(frameInfo, rendererProcessResult);

                                BOOL hasNext = FALSE;
                                CHECK_FAILURE(iterator->MoveNext(&hasNext));
                                frameInfoCount++;
                            }
                            rendererProcessResult.insert(
                                0, std::to_wstring(frameInfoCount) +
                                       L" frameInfo(s) found in Renderer Process ID:" +
                                       std::to_wstring(processId) + L"\n");
                            result.append(rendererProcessResult + L"\n");
                            rendererProcessCount++;
                        }
                        else
                        {
                            otherProcessResult.append(
                                L"Process Id:" + std::to_wstring(processId) +
                                L" | Process Kind:" + ProcessKindToString(kind) + L"\n");
                        }
                    }
                    result.insert(
                        0, std::to_wstring(processCount) + L" process(es) found, from which " +
                               std::to_wstring(rendererProcessCount) +
                               L" renderer process(es) found\n\n");
                    otherProcessResult.insert(
                        0, L"\nRemaining " +
                               std::to_wstring(processCount - rendererProcessCount) +
                               L" Process(es) Infos:\n");
                    result.append(otherProcessResult);
                    MessageBox(
                        nullptr, result.c_str(), L"Process Info with Associated Frames", MB_OK);
                    return S_OK;
                })
                .Get()));