【问题标题】:Is there a way to get the Microsoft Office Version and it's License installed on the Computer? [duplicate]有没有办法让 Microsoft Office 版本和它的许可证安装在计算机上? [复制]
【发布时间】:2020-04-12 14:33:52
【问题描述】:

我正在尝试获取我的 PC 的规格。该系统用于监控计算机上安装的 Office 和 License。我必须在互联网上搜索它,但我什么也没看到。我正在使用 c#。

谁能帮帮我,谢谢和问候

【问题讨论】:

    标签: c# ms-office


    【解决方案1】:

    试试看

    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

    【讨论】:

    • 我试过了,但是返回值是12,而我的office版本是7。
    • 没错。如果 Office 的版本是 2007,则返回 12。查看它 Office 97 - 7 Office 98 - 8 Office 2000 - 9 Office XP - 10 Office 2003 - 11 Office 2007 - 12 Office 2010 - 14 Office 2013 - 15 Office 2016 - 16
    • 啊……好的,先生。谢谢你。而已。上帝保佑哈哈
    猜你喜欢
    • 2019-08-23
    • 2020-09-21
    • 1970-01-01
    • 2022-10-17
    • 2015-09-06
    • 2022-01-02
    • 2010-09-21
    • 1970-01-01
    • 2012-12-30
    相关资源
    最近更新 更多