1. 程式人生 > >使用User-Agent獲取作業系統名稱

使用User-Agent獲取作業系統名稱

60 ///<summary>61 /// 根據 User Agent 獲取作業系統名稱
62 ///</summary> 63 privatestring GetOSNameByUserAgent(string userAgent)
64 {
65 string osVersion ="未知";
66 if (userAgent.Contains("NT 6.2"))
67 {
68 osVersion ="Windows 8/Windows Server 2012";
69 }
70 elseif (userAgent.Contains("NT 6.1"))
71 {
72 osVersion ="Windows 7/Windows Server 2008 R2

";
73 }
74 elseif (userAgent.Contains("NT 6.0"))
75 {
76 osVersion ="Windows Vista/Server 2008";
77 }
78 elseif (userAgent.Contains("NT 5.2"))
79 {
80 osVersion ="Windows Server 2003";
81 }
82 elseif (userAgent.Contains("NT 5.1"))
83 {
84 osVersion ="Windows XP";
85 }
86 elseif (userAgent.Contains("NT 5"))
87 {
88 osVersion
="Windows 2000";
89 }
90 elseif (userAgent.Contains("NT 4"))
91 {
92 osVersion ="Windows NT4";
93 }
94 elseif (userAgent.Contains("Me"))
95 {
96 osVersion ="Windows Me";
97 }
98 elseif (userAgent.Contains("98"))
99 {
100 osVersion ="Windows 98";
101 }
102 elseif (userAgent.Contains("95"))
103 {
104 osVersion ="Windows 95";
105
}
106 elseif (userAgent.Contains("Mac"))
107 {
108 osVersion ="Mac";
109 }
110 elseif (userAgent.Contains("Unix"))
111 {
112 osVersion ="UNIX";
113 }
114 elseif (userAgent.Contains("Linux"))
115 {
116 osVersion ="Linux";
117 }
118 elseif (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”