Programmatically determine which iFilters are installed
Asked Answered
C

4

4

I have a problem whereby the Adobe PDF iFilter doesn't work consistently for us. As such, we like to use the one from Foxit. The problem is, if we install the Foxit iFilter and then later the client decides to reinstall Adobe Reader it may overwrite the Foxit iFilter.

We can use tools such as IFilter Explorer to view this but I'd like a way to do this in the application and warn the user/client that the iFilter has changed.

Is there a way to check iFilters from code (C#)? Or other potential solutions to this problem?

Caudate answered 8/9, 2009 at 14:32 Comment(2)
Sooooo .. did you ever figure out how to check if a iFilter exists from code?Grimes
@KP - No I didn't. Gave up and instead of doing it in code have left it up to the user and documentation to handle, not a real solution but the best we can do for now.Caudate
C
3

Since the foxit IFilter implements IPersistStream interface, I think you can try get this interface from the IFilter, and query for its CLSID to see if it is the one from foxit. Foxit IFilter has a CLSID of {987f8d1a-26e6-4554-b007-6b20e2680632}, which is the "Persistent Handlers Addins Registered" column in IFilter Explorer.

Adobe's IFilter doesn't seem to be implementing this interface.

Chaise answered 11/2, 2011 at 15:12 Comment(2)
I'll give this one the check for the correct answer as it's as close as can be. There appears to be no simple way to enumerate all the iFilters, but Smithy is right, if you know what you are looking for you can dig and determine if that one is installed (assuming it exposes an interface etc.)Caudate
Thank you for the check. And I just discovered the FiltReg.exe command line utility from my Windows SDK. It gives you a full list of installed IFilters on the system. If you can just parse its output...Chaise
O
1

I would expect that IFilters are stored in the registry, therefore you could use Process Monitor to see what keys IFilter Explorer is checking.

Then check on MSDN that this is consistent with the documentation.

Then do the same thing using .NET's registry types in your application.

Based on hunting for this answer, the registration can exist at both System and User level, so you are likely going to need to enumerate multiple registry keys.

Orpington answered 8/9, 2009 at 16:28 Comment(0)
F
0

A little strange answer ;) but as alternative way can be used external console app Filtreg.exe from Windows 7 SDK to delegate this job to it.

Flyblown answered 20/9, 2014 at 18:51 Comment(0)
A
-1

I'm using this small function to give out a list. It just uses the extension NOT the document type! In the most cases this is ok and could be easily changed here.

/// <summary>
/// Implements a Function to get all available IFilters currently registered in this system
/// </summary>    
public string GetFilterList()
{
    //Our resulting string. We give back a ';' seperated list of extensions.
    string result = @"";
    string persistentHandlerClass;

    RegistryKey rk = Registry.LocalMachine.OpenSubKey(@"Software\Classes");
    if (rk == null)
        return null;

    using (rk)
    {
        foreach(string subKeyName in rk.GetSubKeyNames())
        {
            if (subKeyName[0] == '.') //possible Extension
            {
                RegistryKey sk = Registry.LocalMachine.OpenSubKey(@"Software\Classes\" + subKeyName + @"\PersistentHandler");
                if (sk == null)
                    continue;

                using (sk)
                {
                    persistentHandlerClass = (string)sk.GetValue(null);
                }

                if (persistentHandlerClass != null)
                {
                    string filterPersistClass = ReadStrFromHKLM(@"Software\Classes\CLSID\" + persistentHandlerClass +
                        @"\PersistentAddinsRegistered\{89BCB740-6119-101A-BCB7-00DD010655AF}");
                    string dllName = ReadStrFromHKLM(@"Software\Classes\CLSID\" + filterPersistClass + @"\InprocServer32");

                    // skip query.dll results, cause it's not an IFilter itself
                    if (dllName != null && filterPersistClass != null && (dllName.IndexOf("query.dll") < 0))
                    {
                        //result = result + subKeyName + @"[" + dllName + @"] - persistentHandlerClassAddin: " + persistentHandlerClass + "\r\n";  //[C:\Windows\system32\query.dll]
                        //result = result + subKeyName + @"[" + dllName + @"];";  //[C:\Windows\system32\query.dll]
                        result = result + subKeyName.ToLower() + @";";
                    }
                }

            }
        }

        return result;
    }

}
Aldarcie answered 5/4, 2012 at 13:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.