现在我有这个 C++ 函数(删除了安全检查和一些代码以使其更具可读性):
\n\nHRESULT WalkTreeWithAccessibleChildren(wstringstream *ss, IAccessible* pAcc, int depth)\n{\n\xc2\xa0 \xc2\xa0 long childCount;\n\xc2\xa0 \xc2\xa0 long returnCount; \n\n\xc2\xa0 \xc2\xa0 VARIANT* pArray = new VARIANT[childCount];\n\xc2\xa0 \xc2\xa0 hr = AccessibleChildren(pAcc, 0L, childCount, pArray, &returnCount);\n\xc2\xa0 \xc2\xa0 for (int x = 0; x < returnCount; x++) {\n\xc2\xa0 \xc2\xa0 \xc2\xa0 \xc2\xa0 VARIANT vtChild = pArray[x];\n Get the role and name of the component here\n\xc2\xa0 \xc2\xa0 \xc2\xa0 \xc2\xa0 // If it's an accessible object, get the IAccessible, and recurse.\n\xc2\xa0 \xc2\xa0 \xc2\xa0 \xc2\xa0 if (vtChild.vt == VT_DISPATCH) …Run Code Online (Sandbox Code Playgroud)