From: Yoavo on
Hi,
How can I retrieve the Windows OS version as string ?
I need to present this information in my application GUI.
I am familier with the functions that retrieve this information as enum, but
I do not want to parse it myself (and need to update the code every time a
new OS will be released).

In other words, I need the information that presented in "My Computer" ->
"Properties" (under "Windows Edition" section).

thanks,
Yoav.

From: Peter Duniho on
Yoavo wrote:
> Hi,
> How can I retrieve the Windows OS version as string ?
> I need to present this information in my application GUI.
> I am familier with the functions that retrieve this information as enum,
> but I do not want to parse it myself (and need to update the code every
> time a new OS will be released). [...]

What functions are you familiar with? The .NET ones provide just what
I'd think you'd want, including a pre-formatted string. See the
System.Environment.OSVersion.VersionString property.

Pete
From: Jackie on
On 5/20/2010 09:48, Yoavo wrote:
> Hi,
> How can I retrieve the Windows OS version as string ?
> I need to present this information in my application GUI.
> I am familier with the functions that retrieve this information as enum,
> but I do not want to parse it myself (and need to update the code every
> time a new OS will be released).
>
> In other words, I need the information that presented in "My Computer"
> -> "Properties" (under "Windows Edition" section).
>
> thanks,
> Yoav.
>


Like Peter said, Environment.OSVersion should be the .NET method to get
version information. It will however not show the product name (such as
XP, Vista or Windows 7), but instead something similar to "Microsoft
Windows NT 6.1.7600.0". Your application will need to know the the
product names and check Platform and Version to identify which one it is.
http://msdn.microsoft.com/en-us/library/system.environment.osversion.aspx

You can also retrieve the product name with WMI:
Win32_OperatingSystem.Caption
http://msdn.microsoft.com/en-us/library/aa394239%28VS.85%29.aspx

"Short description of the object�a one-line string. The string includes
the operating system version. For example, "Microsoft Windows XP
Professional Version = 5.1.2500". This property can be localized."
From: Fred Mellender on
How about :

OperatingSystem os = Environment.OSVersion;
string foo = os.ToString();
to get: foo = "Microsoft Windows NT 6.1.7600.0"

"Yoavo" <yoav(a)cimatron.co.il> wrote in message
news:#DMPzD$9KHA.4816(a)TK2MSFTNGP02.phx.gbl...
> Hi,
> How can I retrieve the Windows OS version as string ?
> I need to present this information in my application GUI.
> I am familier with the functions that retrieve this information as enum,
> but I do not want to parse it myself (and need to update the code every
> time a new OS will be released).
>
> In other words, I need the information that presented in "My Computer" ->
> "Properties" (under "Windows Edition" section).
>
> thanks,
> Yoav.
>
From: Arne Vajhøj on
On 20-05-2010 03:48, Yoavo wrote:
> Hi,
> How can I retrieve the Windows OS version as string ?
> I need to present this information in my application GUI.
> I am familier with the functions that retrieve this information as enum,
> but I do not want to parse it myself (and need to update the code every
> time a new OS will be released).
>
> In other words, I need the information that presented in "My Computer"
> -> "Properties" (under "Windows Edition" section).

using System;
using System.Management;

namespace E
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine(Environment.OSVersion);
ObjectQuery wmios = new WqlObjectQuery("SELECT * FROM
Win32_OperatingSystem");
ManagementObjectSearcher oss = new
ManagementObjectSearcher(wmios);
foreach (ManagementObject os in oss.Get())
{
Console.WriteLine(os["Caption"]);
}
}
}
}

should display something.

Arne
 | 
Pages: 1
Prev: interface
Next: regular expression