使用User-Agent获取操作系统名称

60 /// <summary>
61 /// 根据 User Agent 获取操作系统名称
62 /// </summary>
63 private string GetOSNameByUserAgent(string userAgent)
64 {
65 string osVersion = "未知";
66 if (userAgent.Contains("NT 6.2"))
67 {
68 osVersion = "Windows 8/Windows Server 2012";
69 }
70 else if (userAgent.Contains("NT 6.1"))
71 {
72 osVersion = "Windows 7/Windows Server 2008 R2";
73 }
74 else if (userAgent.Contains("NT 6.0"))
75 {
76 osVersion = "Windows Vista/Server 2008";
77 }
78 else if (userAgent.Contains("NT 5.2"))
79 {
80 osVersion = "Windows Server 2003";
81 }
82 else if (userAgent.Contains("NT 5.1"))
83 {
84 osVersion = "Windows XP";
85 }
86 else if (userAgent.Contains("NT 5"))
87 {
88 osVersion = "Windows 2000";
89 }
90 else if (userAgent.Contains("NT 4"))
91 {
92 osVersion = "Windows NT4";
93 }
94 else if (userAgent.Contains("Me"))
95 {
96 osVersion = "Windows Me";
97 }
98 else if (userAgent.Contains("98"))
99 {
100 osVersion = "Windows 98";
101 }
102 else if (userAgent.Contains("95"))
103 {
104 osVersion = "Windows 95";
105 }
106 else if (userAgent.Contains("Mac"))
107 {
108 osVersion = "Mac";
109 }
110 else if (userAgent.Contains("Unix"))
111 {
112 osVersion = "UNIX";
113 }
114 else if (userAgent.Contains("Linux"))
115 {
116 osVersion = "Linux";
117 }
118 else if (userAgent.Contains("SunOS"))
119 {
120 osVersion = "SunOS";
121 }
122 return osVersion;
123 }

 

//其它系统对照信息

Windows 7 – “Windows NT 6.1″
Windows Vista – “Windows NT 6.0″
Windows 2003, – “Windows NT 5.2″
Windows XP – “Windows NT 5.1″
Windows 2000, – “Windows NT 5.0″
Windows 98, – “98″
Windows Longhorn, – “Longhorn”
Mac OS, – “Mac”
Linux, – Linux
AIX, – “AIX”
Amiga, – “AmigaOS”
BeOS, – “BEOS”
FreeBSD, – “FreeBSD”
HP Unix, – “HP-UX”
IRIX, – “IRIX”
MSN TV (WebTV), – “WebTV”
OpenBSD, – “OpenBSD”
OS/2,”OS/2″
OSF1, – “OSF1″
Sun OS, – “SUN”
Windows 3.x, – “Windows 3.1″
Windows 95, – “95″
Windows Blackcomb, – “Blackcomb”
Windows CE, – “Windows CE”
Windows ME, – “ME”
Windows NT, – “Windows NT” “WinNT4″
Windows Win32s, – “Win32″
X Windows, – “X Window”

 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值