tags:

views:

259

answers:

1

I am using VBA (in Access 2003) and I'd like to use the IFilter mechanism to extract the textual contents of files. I found some some nice C++ sample code which makes it look relatively easy, but at the moment I can't even get the DLL call to LoadIFilter to work:

Declare Function LoadIFilter Lib "query.dll" (ByVal pwcsPath As String, _
    ByVal pUnkOuter As Object, ByRef ppIFilter As Object) As Integer

Public Sub DocEx()
    Dim ifilter As Object
    Dim hresult As Integer

    hresult = LoadIFilter("C:\temp\test.txt" & Chr(0), Nothing, ifilter)
    Debug.Print hresult
End Sub

hresult is always E_FAIL (= 16389).

Is it my syntax for the DLL that is incorrect, or something else?

EDITED TO ADD: In the end I didn't solve this problem. But since my only purpose is to hack up an internal script, it is sufficient for me to to just call the FiltDump.exe tool that comes bundled with the Microsoft Platform SDK and parse its output. (A bit clunky though, especially since FiltDump.exe insists on printing error messages to stdout instead of stderr!)

A: 

LoadIFilter() is meant to do a lot of work - it looks up the registry to find which IFilter to load, then loads it (most likely calls CoCreateInstance() for just found class id). Anything could go wrong - there could be no mapping in the registry from .txt extension to the class id or the COM server for that class id could fail to load.

Your best bet is to use Process Monitor to see if it finds what IFilter to load and if at least it tries to load it.

sharptooth
Good idea, thanks. For a correct implementation to compare against, I found the testing tools in the Windows SDK: http://msdn.microsoft.com/en-us/library/ms692563(VS.85).aspx
Todd Owen