C# 获取windows系统版本信息

static void Main(string[] args)
{
  Console.WriteLine(GetWindowsVer("Windows 10"));
}

static bool GetWindowsVer(string targetVer)
{
var reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion");
string productName = (string)reg.GetValue("ProductName");
return productName.StartsWith(targetVer);
}

posted @ 2021-02-16 10:41  名字已被使用N次  阅读(777)  评论(0编辑  收藏  举报