if (dispidMember == DISPID_BEFORENAVIGATE2)
{
// Get the WebBrowser's document object
//你要实现的代码有可能是这样, 判断网址,处理之
BSTR bstr = pDispParams->rgvarg[5].pvarVal->bstrVal;
int a = SysStringLen(bstr);
if (a && wcscmp(bstr, L"http://www.sina.com.cn/") == 0)
*pDispParams->rgvarg[0].pboolVal = VARIANT_TRUE;
pDisp
[in] Pointer to the IDispatch interface for the WebBrowser object that represents the window or frame. This interface can be queried for the IWebBrowser2 interface.
url
[in] Pointer to a VARIANT structure of type VT_BSTR that contains the URL to be navigated to.
Flags
[in] Reserved. Must be set to NULL.
TargetFrameName
[in] Pointer to a VARIANT structure of type VT_BSTR that contains the name of the frame in which to display the resource, or NULL if no named frame is targeted for the resource.
PostData
[in] Pointer to a VARIANT structure of type VT_BYREF|VT_VARIANT that contains the data to send to the server if the HTTP POST transaction is being used.
Headers
[in] Pointer to a VARIANT structure of type VT_BSTR that contains additional HTTP headers to send to the server (HTTP URLs only). The headers can specify things such as the action required of the server, the type of data being passed to the server, or a status code.
Cancel
[in, out] Pointer to a VARIANT structure of type VARIANT_BOOL that contains the cancel flag. An application can set this parameter to VARIANT_TRUE to cancel the navigation operation, or to VARIANT_FALSE to allow it to proceed.
Return Value
No return value.
Event DISPID
DISPID_BEFORENAVIGATE
The DISPID for this event is defined in exdispid.h. Use this value to identify the event handler when implementing IDispatch::Invoke.
Remarks
This event is obsolete. Use the DWebBrowserEvents2::BeforeNavigate2 event instead.
是这个吗:
Headers
[in] Pointer to a VARIANT structure of type VT_BSTR that contains additional HTTP headers to send to the server (HTTP URLs only). The headers can specify things such as the action required of the server, the type of data being passed to the server, or a status code.