Introduction
When you visit a Web page, your browser sends the user-agent string to the server hosting the site that you are visiting. This string indicates which browser you are using, its version number, and details about your system, such as operating system and version. The Web server can use this information to provide content that is tailored for your specific browser.
The following figure shows a sample user-agent string reported by Internet Explorer that highlights its tokens.

A typical Internet Explorer user-agent string.

For historical reasons, Internet Explorer identifies itself as a Mozilla 4.0 browser.

The sample user-agent string contains three tokens.

1.The Compatibility flag ("compatible") is used by most modern browsers. It indicates that Internet Explorer is compatible with a common set of features.

2.The Version token identifies the browser and contains the version number. The version token in the example ("MSIE 7.0") identifies Internet Explorer 7.

3.The Platform token identifies your operating system and contains the version number. The platform token in the example ("Windows NT 6.0") indicates Windows Vista.

In the example, Internet Explorer is the user agent. However, other programs also provide user-agent strings when contacting servers over the Internet. For example, the Windows RSS Platform provides the following user-agent header when requesting RSS data.

Windows-RSS-Platform/1.0 (MSIE 7.0; Windows NT 5.1)

Like the user-agent string for Internet Explorer, this user-agent header provides details about your system.

Alternate tokens can appear in the user-agent string for a number of reasons; usually, they identify optional features installed on your system. For example, an "SV1" token appears in the user-agent string of a Windows XP user who has installed Windows XP Service Pack 2 (SP2). It is also important to note that certain non-Microsoft parties modify the user-agent string for their own purposes.

Note: To protect your privacy, you should periodically review your user-agent string and verify its contents.
User-Agent Registry Keys

When you install certain Windows components, such as the Microsoft .NET Framework or Windows XP SP2, tokens are added to the user-agent string. This is done by adding tokens to the following registry keys.

HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER)
     SOFTWARE
          Microsoft
               Windows
                    CurrentVersion
                         Internet Settings
                              User Agent
                                   Pre Platform
                                        Token = Value
                                   Post Platform
                                        Token = Value

The Pre-Platform and Post-Platform keys contain values whose names appear before and after the Platform token, respectively. For example, if a string value is added to the Post-Platform key, the name appears after the platform token in the user-agent string. Multiple tokens added to either key appear in an unpredictable order.

You can also override certain tokens of the user-agent string by adding values to the following registry key.

HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER)
     SOFTWARE
          Microsoft
               Windows
                    CurrentVersion
                         Internet Settings
                              5.0
                                   User Agent
                                        (default) = "Mozilla/4.0"
                                        Compatible = "compatible"
                                        Platform = "Windows NT 5.1"
                                        Version = "MSIE 6.0"
                                        Pre Platform
                                             Token = Value
                                        Post Platform
                                             Token = Value

我在Internet Settings\User Agent\Pre Platform下添加HelloPrePlatform,在Internet Settings\User Agent\Post Platform下添加HelloPostPlatform,在Internet Settings\5.0\User Agent\Pre Platform下添加Hello5.0PrePlatform,在Internet Settings\5.0\User Agent\Post Platform下添加Hello5.0PostPlatform,在Internet Settings\User Agent下添加HelloUserAgent,在Internet Settings\5.0\User Agent下添加Hello5.0UserAgent查看IE的useragent的结果是

HelloUserAgent
Mozilla/4.0 (compatible; MSIE 8.0; HelloPrePlatform; Windows NT 6.1; Trident/4.0; MS-OC 4.0; HelloPostPlatform; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; CIBA; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; Hello5.0PostPlatform)
italics tokens are all in Internet Settings\5.0\User Agent\Post Platform
How to detect Browser version with JavaScript

How to detect Browser version with C#(Silverlight)


Ref:http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx