interface ICoreWebView2Environment2
interface ICoreWebView2Environment2
: public ICoreWebView2Environment
A continuation of the ICoreWebView2Environment interface.
Summary
Members | Descriptions |
---|---|
CreateWebResourceRequest | Create a new web resource request object. |
Applies to
Product | Introduced |
---|---|
WebView2 Win32 | 1.0.705.50 |
WebView2 Win32 Prerelease | 1.0.721 |
Members
CreateWebResourceRequest
Create a new web resource request object.
public HRESULT CreateWebResourceRequest(LPCWSTR uri, LPCWSTR method, IStream * postData, LPCWSTR headers, ICoreWebView2WebResourceRequest ** request)
URI parameter must be absolute URI. The headers string is the raw request header string delimited by CRLF (optional in last header). It's also possible to create this object with null headers string and then use the ICoreWebView2HttpRequestHeaders to construct the headers line by line. For information on other parameters see ICoreWebView2WebResourceRequest.
wil::com_ptr<ICoreWebView2Environment2> webviewEnvironment2;
CHECK_FAILURE(appWindow->GetWebViewEnvironment()->QueryInterface(
IID_PPV_ARGS(&webviewEnvironment2)));
wil::com_ptr<ICoreWebView2WebResourceRequest> webResourceRequest;
wil::com_ptr<IStream> postDataStream = SHCreateMemStream(
reinterpret_cast<const BYTE*>(postDataBytes.get()), sizeNeededForMultiByte);
// This is acts as a form submit to https://www.w3schools.com/action_page.php
CHECK_FAILURE(webviewEnvironment2->CreateWebResourceRequest(
L"https://www.w3schools.com/action_page.php", L"POST", postDataStream.get(),
L"Content-Type: application/x-www-form-urlencoded", &webResourceRequest));
wil::com_ptr<ICoreWebView2_2> webview2;
CHECK_FAILURE(m_appWindow->GetWebView()->QueryInterface(IID_PPV_ARGS(&webview2)));
CHECK_FAILURE(webview2->NavigateWithWebResourceRequest(webResourceRequest.get()));
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應