Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check MSWord is Installed in system

Tags:

c#

ms-word

Exact Duplicate:

C#: How to know whether certain Office 2003 or 2007 application is installed?

How to check if MSWord 2003 0r 2007 is installed in the system using C# code?

like image 495
Sauron Avatar asked May 22 '09 12:05

Sauron


1 Answers

This code shows that a simple registry check will do the job.

Here is the code converted to C# (and slightly improved to use a using statement).

using Microsoft.Win32;

// Check whether Microsoft Word is installed on this computer,
// by searching the HKEY_CLASSES_ROOT\Word.Application key.
using (var regWord = Registry.ClassesRoot.OpenSubKey("Word.Application"))
{
    if (regWord == null)
    {
        Console.WriteLine("Microsoft Word is not installed");
    }
    else
    {
        Console.WriteLine("Microsoft Word is installed");
    }
}

Note that it's not good enough to check C:\Program Files\Microsoft Office\ for the msword EXE file, as the user might have installed it somewhere else.

like image 198
Noldorin Avatar answered Sep 19 '22 10:09

Noldorin