title: Obtaining IAccessible2 interface for Firefox / Thunderbird window - QueryService always returns E_INVALIDARG
body: <p>I am trying out accessing the information in (Windows only) Firefox / Thunderbird using the IAccessible2 API: <a href="http://www.linuxfoundation.org/collaborate/workgroups/accessibility/iaccessible2" rel="nofollow">http://www.linuxfoundation.org/collaborate/workgroups/accessibility/iaccessible2</a>
  However I'm failing at almost the first step.  I can obtain the IAccessible interface for either application, and then the IServiceProvider interface.  But when I call QueryService to obtain the IAccessible2 interface, as described here: <a href="http://accessibility.linuxfoundation.org/a11yspecs/ia2/docs/html/_generalinfo.html#_dicoveringInterfaces" rel="nofollow">http://accessibility.linuxfoundation.org/a11yspecs/ia2/docs/html/_generalinfo.html#_dicoveringInterfaces</a> it always returns E_INVALIDARG.</p>
  
  <p>AccProbe successfully returns IA2 information for both applications.  The MS documentation for QueryService doesn't list E_INVALIDARG as a possible return value.  However browsing for the mozilla source it appears that it returns this if the first parameter (service ID) is unexpected, and otherwise calls through to QueryInterface (which would return E_NOINTERFACE for a bad interface ID).  So... that implies the first parameter to QueryService is wrong;  but I've tried pretty much every value I think mozilla expects with no difference.</p>
  
  <p>I started off in c# and then tried again in c++ in case I was losing something in InterOp.  Same result in both languages.  Here's my current c++ test code:</p>
  
  <pre><code>    HWND hw = GetForegroundWindow();
      IAccessible *pIA;
      HRESULT hr = AccessibleObjectFromWindow(hw, OBJID_WINDOW, IID_IAccessible, (void**)&amp;pIA);
      if (!SUCCEEDED(hr))
          return -1;
  
      // SNIP - calls pIA-&gt;get_accName to check correct window is being accessed.  This works OK.
  
      const IID IID_IAccessible2 = {0xE89F726E, 0xC4F4, 0x4c19, 0xbb, 0x19, 0xb6, 0x47, 0xd7, 0xfa, 0x84, 0x78};
      ::IServiceProvider *pService = NULL; 
      hr = pIA-&gt;QueryInterface(IID_IServiceProvider, (void **)&amp;pService); 
      if(SUCCEEDED(hr))
      {
          IAccessible2 *pIA2 = NULL; 
          hr = pService-&gt;QueryService(IID_IAccessible2, IID_IAccessible2, (void**)&amp;pIA2); 
          if (SUCCEEDED(hr) &amp;&amp; pIA2)
          { 
            // Always fails with E_INVALIDARG
              pIA2-&gt;Release();
          } 
          pService-&gt;Release();
      } 
  </code></pre>
  
  <p>This is all on Win7 - both 32-bit and 64-bit used.  Firefox 3.6.24 and Thunderbird 8.0.  Visual Studio 2005</p>
  
  <p>Am I doing something wrong?</p>