title: Is there a way to make MSAA IAccessible traversal faster?
body: <p>Right now I have this C++ function (removed safety checks and some code to make it more readable):</p>
  
  <pre><code>HRESULT WalkTreeWithAccessibleChildren(wstringstream *ss, IAccessible* pAcc, int depth)
  {
      long childCount;
      long returnCount;   
  
      VARIANT* pArray = new VARIANT[childCount];
      hr = AccessibleChildren(pAcc, 0L, childCount, pArray, &amp;returnCount);
      for (int x = 0; x &lt; returnCount; x++) {
          VARIANT vtChild = pArray[x];
          Get the role and name of the component here
          // If it's an accessible object, get the IAccessible, and recurse.
          if (vtChild.vt == VT_DISPATCH) {
              IDispatch* pDisp = vtChild.pdispVal;
              IAccessible* pChild = NULL;
              hr = pDisp-&gt;QueryInterface(IID_IAccessible, (void**) &amp;pChild);
              WalkTreeWithAccessibleChildren(ss, pChild, depth + 1);
      }
  }
  </code></pre>
  
  <p>For some programs with relatively few components (200 or so), e.g. Paint.NET, this takes about 2 full seconds, is there a way I can make this function faster, get all of the components in one COM call or something like that?</p>