title: Use IFilter from VB
body: <p>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++ <a href="http://the-lazy-programmer.com/blog/?p=8" rel="nofollow noreferrer">sample code</a> which makes it look relatively easy, but at the moment I can't even get the DLL call to <a href="http://msdn.microsoft.com/en-us/library/ms691002(VS.85).aspx" rel="nofollow noreferrer">LoadIFilter</a> to work:</p>
  
  <pre><code>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" &amp; Chr(0), Nothing, ifilter)
      Debug.Print hresult
  End Sub
  </code></pre>
  
  <p>hresult is always E_FAIL (= 16389).</p>
  
  <p>Is it my syntax for the DLL that is incorrect, or something else?</p>
  
  <p><strong>EDITED TO ADD:</strong> 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!)</p>