如何将MS windows *** 作系统版本号翻译成产品名称?
例如,在.NET中,可以使用以下两个属性来确定该产品是MS windows Vista ultimate Edition:
Environment.Osversion.Platform returns Win32NT
Environment.Osversion.Version returns 6.0.6001.65536
Visual Basic:重新启动桌面windowspipe理器(DWM)
通过远程桌面提高WPF应用程序的速度?
自定义DataGrIDVIEwRow问题:获取自定义属性始终是默认值(false)
在windows Vista / 7(使用DWM)中redirect应用程序的graphics输出
如何获得任务栏的背景颜色
如何在.NET中加载插件?
windows / .NET的方式来监视/deBUGging串口?
如何从Web服务器打印格式化的文本并确认打印成功?
windows快速移动时改变光标
用于windows 98的.NET 2.0应用程序的安装程序
如何净os版本
VB:
Public Function Getosversion() As String Select Case Environment.Osversion.Platform Case PlatformID.Win32S Return "Win 3.1" Case PlatformID.Win32windows Select Case Environment.Osversion.Version.Minor Case 0 Return "Win95" Case 10 Return "Win98" Case 90 Return "WinME" Case Else Return "UnkNown" End Select Case PlatformID.Win32NT Select Case Environment.Osversion.Version.Major Case 3 Return "NT 3.51" Case 4 Return "NT 4.0" Case 5 Select Case _ Environment.Osversion.Version.Minor Case 0 Return "Win2000" Case 1 Return "WinXP" Case 2 Return "Win2003" End Select Case 6 Select Case _ Environment.Osversion.Version.Minor Case 0 Return "Vista/Win2008server" Case 1 Return "Win7/Win2008server R2" Case 2 Return "Win8/Win2012server" Case 3 Return "Win8.1/Win2012server R2" End Select Case 10 //this will only show up if the application has a manifest file allowing W10,otherwise a 6.2 version will be used Return "windows 10" Case Else Return "UnkNown" End Select Case PlatformID.WinCE Return "Win CE" End Select End Function
C#
public string Getosversion() { switch (Environment.Osversion.Platform) { case PlatformID.Win32S: return "Win 3.1"; case PlatformID.Win32windows: switch (Environment.Osversion.Version.Minor) { case 0: return "Win95"; case 10: return "Win98"; case 90: return "WinME"; } break; case PlatformID.Win32NT: switch (Environment.Osversion.Version.Major) { case 3: return "NT 3.51"; case 4: return "NT 4.0"; case 5: switch (Environment.Osversion.Version.Minor) { case 0: return "Win2000"; case 1: return "WinXP"; case 2: return "Win2003"; } break; case 6: switch(Environment.Osversion.Version.Minor) { case 0: return "Vista/Win2008server"; case 1: return "Win7/Win2008server R2"; case 2: return "Win8/Win2012server"; case 3: return "Win8.1/Win2012server R2"; } break; case 10: //this will only show up if the application has a manifest file allowing W10,otherwise a 6.2 version will be used return "windows 10"; } break; case PlatformID.WinCE: return "Win CE"; } return "UnkNown"; }
您可以使用WMI获取友好的产品名称(“Microsoft®windowsserver®2008 Enterprise”):
using System.Management; var name = (from x in new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem").Get().OfType<ManagementObject>() select x.GetPropertyValue("Caption")).First(); return name != null ? name.ToString() : "UnkNown";
在msdn http://msdn.microsoft.com/en-us/library/ms724429(VS.85).aspx上有一个C ++的例子,还有一个关于如何在[VB]中使用它来添加的注释。净。 它看起来像你需要的“失踪”位是Win32函数GetProductInfo ( PInvoke.net参考 )。
在这个和Avram的答案之间,你应该能够组装完整版本的字符串。
这是我的解决方案,速度最快,没有选择案例。
结果可以根据需要自定义
public static string SistemaOperativo { get { #region Dichiarazioni var osInfo = Environment.Osversion; int platformID = (int)osInfo.Platform; int versionM = osInfo.Version.Major; int versionm = osInfo.Version.Minor; string servicePack = osInfo.ServicePack; #endregion #region SpIEgazione logica /* * IT: * La chiave del dizionario è il risultato del concatenamento di * PlatformID,MajorVersion,MinorVersion,tutto convertito in Int32,* per esempio Platform ID=1 MajorVersion=4 MinorVersion=0,* il risultato è 140 ossia windows 95 * * EN: * The key in Dictionary is the 'join' * of PlatformID,in int32,* eg. Platform ID=1 MajorVersion=4 MinorVersion=0,* the result is '140' (windows 95) */ #endregion Dictionary<int,string> sistemiOperativi = new Dictionary<int,string>(){ {0,"windows 3.1"},{140,"windows 95"},{1410,"windows 98"},{1490,"windows ME"},{2351,"windows NT 3.51"},{240,"windows 4.0"},{250,"windows 2000"},{251,"windows XP"},{252,"windows 2003"},{260,"windows Vista/server 2008"},{261,"windows 7"},{-1,"UnkNown"} }; int IDUnivoco = int.Parse(string.Format("{0}{1}{2}",platformID,versionM,versionm)); string outValue = ""; if (sistemiOperativi.TryGetValue(IDUnivoco,out outValue)) return string.Format("{0}{1}",outValue,servicePack); return sistemiOperativi[-1]; } }
如果你只是想要一个GUI友好的信息消息我使用
My.Computer.Info.OSFullname&“(”+ My.Computer.Info.Osversion +“)”
似乎是未来windows版本的未来证明
总结以上是内存溢出为你收集整理的如何将MS Windows *** 作系统版本号转换为.NET中的产品名称?全部内容,希望文章能够帮你解决如何将MS Windows *** 作系统版本号转换为.NET中的产品名称?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)