次の方法で共有


interface ICoreWebView2Environment13

interface ICoreWebView2Environment13
  : public ICoreWebView2Environment12

A continuation of the ICoreWebView2Environment interface for getting process with associated information.

Summary

Members Descriptions
GetProcessExtendedInfos Gets a snapshot collection of ProcessExtendedInfos corresponding to all currently running processes associated with this CoreWebView2Environment excludes crashpad process.

Applies to

Product Introduced
WebView2 Win32 1.0.2210.55
WebView2 Win32 Prerelease 1.0.2357

Members

GetProcessExtendedInfos

Gets a snapshot collection of ProcessExtendedInfos corresponding to all currently running processes associated with this CoreWebView2Environment excludes crashpad process.

public HRESULT GetProcessExtendedInfos(ICoreWebView2GetProcessExtendedInfosCompletedHandler * 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 or hiding UI elements) in the renderer process. See AssociatedFrameInfos for more information.

        CHECK_FAILURE(environment13->GetProcessExtendedInfos(
            Callback<ICoreWebView2GetProcessExtendedInfosCompletedHandler>(
                [this](
                    HRESULT error,
                    ICoreWebView2ProcessExtendedInfoCollection* processCollection) -> HRESULT
                {
                    UINT32 processCount = 0;
                    UINT32 rendererProcessCount = 0;
                    CHECK_FAILURE(processCollection->get_Count(&processCount));
                    std::wstringstream otherProcessInfos;
                    std::wstringstream rendererProcessInfos;
                    for (UINT32 i = 0; i < processCount; i++)
                    {
                        Microsoft::WRL::ComPtr<ICoreWebView2ProcessExtendedInfo>
                            processExtendedInfo;
                        CHECK_FAILURE(
                            processCollection->GetValueAtIndex(i, &processExtendedInfo));
                        Microsoft::WRL::ComPtr<ICoreWebView2ProcessInfo> processInfo;
                        CHECK_FAILURE(processExtendedInfo->get_ProcessInfo(&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::wstringstream rendererProcess;
                            wil::com_ptr<ICoreWebView2FrameInfoCollection> frameInfoCollection;
                            CHECK_FAILURE(processExtendedInfo->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, rendererProcess);

                                BOOL hasNext = FALSE;
                                CHECK_FAILURE(iterator->MoveNext(&hasNext));
                                frameInfoCount++;
                            }
                            rendererProcessInfos
                                << frameInfoCount
                                << L" frameInfo(s) found in Renderer Process ID:" << processId
                                << L"\n"
                                << rendererProcess.str() << std::endl;
                            rendererProcessCount++;
                        }
                        else
                        {
                            otherProcessInfos << L"Process Id:" << processId
                                              << L" | Process Kind:"
                                              << ProcessKindToString(kind) << std::endl;
                        }
                    }
                    std::wstringstream message;
                    message << processCount << L" process(es) found, from which "
                            << rendererProcessCount << L" renderer process(es) found\n\n"
                            << rendererProcessInfos.str() << L"Remaining Process(es) Infos:\n"
                            << otherProcessInfos.str();

                    m_appWindow->AsyncMessageBox(
                        std::move(message.str()), L"Process Extended Info");
                    return S_OK;
                })
                .Get()));