Lodle
Lodle

Reputation: 32217

ie useragent wxWidgets

Im currently using ie as an active x com thing on wxWidgets and was wanting to know if there is any easy way to change the user agent that will always work.

Atm im changing the header but this only works when i manually load the link (i.e. call setUrl)

Upvotes: 2

Views: 845

Answers (3)

Lodle
Lodle

Reputation: 32217

I did a bit of googling today with the hint you provided head geek and i worked out how to do it.

wxWidgets uses an activex rapper class called FrameSite that handles the invoke requests. What i did was make a new class that inherits from this, handles the DISPID_AMBIENT_USERAGENT event and passes all others on. Thus now i can return a different user agent.

Thanks for the help.

Upvotes: 1

MSalters
MSalters

Reputation: 180235

Head Geek already told you where in the registy IE will look by default.

This is just a default, though. If you implement [IDocHostUIHandler::GetOptionKeyPath](http://msdn.microsoft.com/en-us/library/aa753258(VS.85%29.aspx) or [IDocHostUIHandler2::GetOverrideKeyPath](http://msdn.microsoft.com/en-us/library/aa753274(VS.85%29.aspx), IE will use that registry entry instead.

You'll probably want to use SysInternal's RegMon to debug this.

Upvotes: 0

Head Geek
Head Geek

Reputation: 39888

The only way that will "always work," so far as I've been able to find, is changing the user-agent string in the registry. That will, of course, affect every web browser instance running on that machine.

You might also try a Google search on DISPID_AMBIENT_USERAGENT. From this Microsoft page:

MSHTML will also ask for a new user agent via DISPID_AMBIENT_USERAGENT when navigating to clicked hyperlinks. This ambient property can be overridden, but it is not used when programmatically calling the Navigate method; it will also not cause the userAgent property of the DOM's navigator object or clientInformation behavior to be altered - this property will always reflect Internet Explorer's own UserAgent string.

I'm not familiar with the MSHTML component, so I'm not certain that's helpful.

I hope that at least gives you a place to start. :-)

Upvotes: 2

Related Questions