熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

用C#來判斷當前系統是XP還是WIN7

2022-06-13   來源: .NET編程 

  直接提供Winform程序

  OperatingSystem os = EnvironmentOSVersion;

  switch (osPlatform)

  {

  case PlatformIDWinWindows:

  switch (osVersionMinor)

  {

  case :

  labelText = "Windows ";

  break;

  case :

  if (osVersionRevisionToString() == "A ")

  labelText = "Windows 第二版 ";

  else

  labelText = "Windows ";

  break;

  case :

  labelText = "Windows Me ";

  break;

  }

  break;

  case PlatformIDWinNT:

  switch (osVersionMajor)

  {

  case :

  labelText = "Windows NT ";

  break;

  case :

  labelText = "Windows NT ";

  break;

  case :

  switch (osVersionMinor)

  {

  case :

  labelText = "Windows ";

  break;

  case :

  labelText = "Windows XP ";

  break;

  case :

  labelText = "Windows ";

  break;

  }

  break;

  case :

  switch (osVersionMinor)

  {

  case :

  labelText = "Windows Vista ";

  break;

  case :

  labelText = "Windows ";

  break;

  }

  break;

  }

  break;

  }

  當然大家直接可以通過 OperatingSystem os = EnvironmentOSVersion;然後判斷osVersionMajor是否是等於就可以判斷系統是不是windows Vista以上版本


From:http://tw.wingwit.com/Article/program/net/201311/14439.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.