【发布时间】:2020-04-12 14:33:52
【问题描述】:
我正在尝试获取我的 PC 的规格。该系统用于监控计算机上安装的 Office 和 License。我必须在互联网上搜索它,但我什么也没看到。我正在使用 c#。
谁能帮帮我,谢谢和问候
【问题讨论】:
我正在尝试获取我的 PC 的规格。该系统用于监控计算机上安装的 Office 和 License。我必须在互联网上搜索它,但我什么也没看到。我正在使用 c#。
谁能帮帮我,谢谢和问候
【问题讨论】:
试试看
System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo
{
WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal,
FileName = "cmd.exe",
RedirectStandardInput = true,
UseShellExecute = false,
Arguments = "/C reg query \"HKEY_CLASSES_ROOT\\Word.Application\\CurVer\""
};
procStartInfo.RedirectStandardOutput = true;
procStartInfo.RedirectStandardError = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
string output = proc.StandardOutput.ReadToEnd();
Console.WriteLine("Output: " + output);
string version = System.Text.RegularExpressions.Regex.Replace(output, "(.*)(Word\\.Application\\.)(\\d+)(.*)", "$3", System.Text.RegularExpressions.RegexOptions.Singleline);
Console.WriteLine("Office version: " + version);
Console.Read();
办公室 97 - 7
办公室 98 - 8
Office 2000 - 9
Office XP - 10
Office 2003 - 11
Office 2007 - 12
办公室 2010 - 14
Office 2013 - 15
Office 2016 - 16
【讨论】: