共用方式為


interface ICoreWebView2Environment7

Note

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

interface ICoreWebView2Environment7
  : public ICoreWebView2Environment6

This interface is an extension of the ICoreWebView2Environment.

Summary

Members Descriptions
get_UserDataFolder Returns the user data folder that all CoreWebView2's created from this environment are using.

An object implementing the ICoreWebView2Environment7 interface will also implement ICoreWebView2Environment.

Applies to

Product Introduced
WebView2 Win32 1.0.1054.31
WebView2 Win32 Prerelease 1.0.1056

Members

get_UserDataFolder

Returns the user data folder that all CoreWebView2's created from this environment are using.

public HRESULT get_UserDataFolder(LPWSTR * value)

This could be either the value passed in by the developer when creating the environment object or the calculated one for default handling. It will always be an absolute path.

The caller must free the returned string with CoTaskMemFree. See API Conventions.

        auto environment7 = m_webViewEnvironment.try_query<ICoreWebView2Environment7>();
        CHECK_FEATURE_RETURN(environment7);
        wil::unique_cotaskmem_string userDataFolder;
        environment7->get_UserDataFolder(&userDataFolder);
        MessageBox(m_mainWindow, userDataFolder.get(), L"User Data Folder", MB_OK);