How do I get information about the version of windows I'm running?

  • Thread starter Thread starter Claire
  • Start date Start date
C

Claire

I need to read data from one of two file locations depending on whether the
application is hosted on Vista or an older version of windows. On older
systems its on a subdirectory of the application, on Vista on
commonapplicationdata.
How do I query windows version please?

thank you
Claire
 
http://msdn.microsoft.com/library/d...ry/en-us/wmisdk/wmi/Win32_OperatingSystem.asp

----

using System;
using System.Management;
using System.Windows.Forms;

namespace WMISample
{
public class MyWMIQuery
{
public static void Main()
{
try
{
ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_OperatingSystem");

foreach (ManagementObject queryObj in searcher.Get())
{

Console.WriteLine("-----------------------------------");
Console.WriteLine("Win32_OperatingSystem
instance");

Console.WriteLine("-----------------------------------");
Console.WriteLine("Version: {0}",
queryObj["Version"]);
}
}
catch (ManagementException e)
{
MessageBox.Show("An error occurred while querying for
WMI data: " + e.Message);
}
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top