Retrieves a string that represents the user-agent header sent in the HTTP protocol from the client to the server.
Syntax
HRESULT get_userAgent( BSTR *p );
Parameters
- p
- Address of a string variable that receives the user-agent header.
Return Value
Returns S_OK if successful, or an error code otherwise.
Windows CE
Windows CE Use version 2.12 and later Minimum availability Internet Explorer 4.0
Example
The following function retrieves the user agent string and returns it through the out parameter, pbstrUA.
// document.parentWindow.navigator.userAgent HRESULT GetUA(IHTMLDocument2* pDoc, BSTR* pbstrUA) { IHTMLWindow2* pWindow = NULL; if (!pDoc) { return E_INVALIDARG; } hr = pDoc->get_parentWindow(&pWindow); if (FAILED(hr) || !pWindow) { return hr; } IOmNavigator* pNavigator = NULL; hr = pWindow->get_navigator(&pNavigator); if (FAILED(hr) || !pNavigator) { goto Error; } hr = pNavigator->get_userAgent(pbstrUA); Error: if (pWindow) pWindow->Release(); if (pNavigator) pNavigator->Release(); return hr; }