-1

I am trying to get the specifications of my PC. This system is used to monitor the installed Office and License on the Computer. I have to search for it on the internet but I have seen nothing. I am using c#.

Can someone help me with this, Thank you and regards

Boooo Booooo
  • 57
  • 1
  • 2
  • 11

1 Answers1

1

Try it

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();

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

Hammad Sajid
  • 312
  • 1
  • 3
  • 14
Khairyi S
  • 306
  • 2
  • 10
  • I have tried it sir, But the return value is 12, but my office version is 7. – Boooo Booooo Dec 20 '19 at 02:42
  • It is right. If the version of Office is 2007, returns 12. See it 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 – Khairyi S Dec 20 '19 at 02:46
  • 1
    Ahh.. Okay sir. Thank you. That's It. God Bless HAHA – Boooo Booooo Dec 20 '19 at 02:49