开发者

Retrieving OS name

开发者 https://www.devze.com 2022-12-23 02:25 出处:网络
Is there any way to get the OS name the user is 开发者_运维百科currently using?You can use System.Environment

Is there any way to get the OS name the user is 开发者_运维百科currently using?


You can use

System.Environment

class

Environment.OSVersion.ToString()

See Environment.OSVersion Property

Gets an OperatingSystem object that contains the current platform identifier and version number.


You can use the Environment.OSVersion property.

Version version = Environment.OSVersion;

To decode the version, refer to the wikipedia page of Microsoft Windows Timeline. For example, if the version is 6.1.7600, then it is either a Windows 7 or a Windows Server 2008 R2.

Note that there is no direct API to get the OS name, because a same version can refer to multiple public OS names.


You cannot retrieve the OS name directly. Instead use the Environment.OSVersion.ToString() property to interpret the version & display the OS Name.

This article has a sample that will help you. It covers Win95 to Win7.

All you need to do is write a function that will return the OS name as shown in the above article.

0

精彩评论

暂无评论...
验证码 换一张
取 消