Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Get OS version (See related posts)

 public static string GetMachineOS()
 {
  if (Environment.OSVersion.Platform == PlatformID.Win32NT)
  {
   if (Environment.OSVersion.Version.Major<=4)
    return String.Format("Windows NT {0}", Environment.OSVersion.Version.ToString());
   if (Environment.OSVersion.Version.Major==5)
   {
    if (Environment.OSVersion.Version.Minor==0)
     return String.Format("Windows 2000 {0}", Environment.OSVersion.Version.ToString());
    else
     return String.Format("Windows XP {0}", Environment.OSVersion.Version.ToString());
   }
  }
   
  if (Environment.OSVersion.Platform == PlatformID.Win32Windows)
  {
   if (Environment.OSVersion.Version.Major>=4)
   {
    if (Environment.OSVersion.Version.Minor==0)
     return String.Format("Windows 95 {0}", Environment.OSVersion.Version.ToString());    
    else if (Environment.OSVersion.Version.Minor<90)
     return String.Format("Windows 98 {0}", Environment.OSVersion.Version.ToString());
    else
     return String.Format("Windows Millenim Edition {0}", Environment.OSVersion.Version.ToString());
   }
  }

  return Environment.OSVersion.ToString(); //ELSE
 }

You need to create an account or log in to post comments to this site.


Click here to browse all 4857 code snippets

Related Posts