After performing a quick Google search, I arrived at the answer to my quest. Here are the results:
It turns out that the System.Environment namespace houses a lot of useful items. One of them is the OSVersion class. The OSVersion.Version property contains the version number which is what I wanted to determine which OS the user host computer is running. The other properties referenced are merely eye-candy.
Using Windows XP:
Using Windows Vista:
Notice how the version number changes from Windows XP to Windows Vista.
To obtain the data shown above, the Environment.OSVersion class is used:
string osVStr = Environment.OSVersion.VersionString;
labelOSVStr.Text = osVStr;
string osVPlatform = Environment.OSVersion.Platform.ToString();
labelOSVPlatform.Text = osVPlatform;
string osVSvcPack = Environment.OSVersion.ServicePack.ToString();
labelOSVSvcPack.Text = osVServicePack;
string osV = Environment.OSVersion.Version.ToString();
labelOSVersion.Text = osV;
From here, it is a simple step to compare version numbers against a desired level, verify that service packs have been applied, etc.
No comments:
Post a Comment