Ai
4 Star 2 Fork 0

Gitee 极速下载/JustDecompile-Engine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/telerik/JustDecompileEngine
克隆/下载
MachineInformation.cs 2.01 KB
一键复制 编辑 原始数据 按行查看 历史
Dimitar Stoykov 提交于 2017-12-19 19:19 +08:00 . Performance improvements for GA
using System;
using System.Diagnostics;
using System.Text.RegularExpressions;
namespace SystemInformationHelpers
{
public class MachineInformation
{
public static string ProcessorCount
{
get
{
return Environment.ProcessorCount.ToString();
}
}
public static string CurrentDotNetVersion
{
get
{
return Framework4VersionResolver.GetInstalledFramework4Version().ToString();
}
}
public static string OSVersion
{
get
{
return GetOSVersion();
}
}
private static string GetOSVersion()
{
string osVersion = string.Empty;
try
{
ProcessStartInfo getOsVersionProcess = new ProcessStartInfo("cmd.exe", "/c ver") { RedirectStandardOutput = true, UseShellExecute = false, CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden };
osVersion = Process
.Start(getOsVersionProcess)
.StandardOutput
.ReadToEnd();
return FormatOSVersionString(osVersion);
}
catch (Exception ex)
{
string osVersionExceptionFormat = "ERROR: " + ex.GetType().Name + " - " + ex.Message;
osVersion = osVersionExceptionFormat;
}
return osVersion;
}
private static string FormatOSVersionString(string osVersion)
{
string formattedOSVersion = osVersion.Trim();
string osVersionRegexPattern = "^Microsoft Windows \\[Version ([0-9\\.]+)\\]$";
Regex regex = new Regex(osVersionRegexPattern);
Match regexMatch = regex.Match(formattedOSVersion);
if (regexMatch.Success)
{
formattedOSVersion = regexMatch.Groups[1].Value;
}
return formattedOSVersion;
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/mirrors/JustDecompile-Engine.git
git@gitee.com:mirrors/JustDecompile-Engine.git
mirrors
JustDecompile-Engine
JustDecompile-Engine
master

搜索帮助