I use the following unmanaged code to search an IAccessible in an IAccessible tree, but the return IAccessible ansIacc in the managed side is always null.
unmanaged code(callee):
extern "C" __declspec(dllexport) HRESULT search(IAccessible * parent, BSTR bstrName, int role, int index_,
_Out_ IAccessible* ansIacc, _Out_ int* left, _Out_ int* top, _Out_ int*width, _Out_ int* height)
{
// the implementation of this function.
// I have checked that the return value of left/top/width/height are right,
// but the ansIacc is null in the c# side
}
managed code(caller):
[DllImport(@"C:\Users\jyppz\source\repos\server\x64\Debug\SearchIAcc.dll",
CallingConvention = CallingConvention.StdCall)]
static extern int search(IAccessible parent, [MarshalAs(UnmanagedType.BStr)] string bstrName, int role, int index, out object ansIacc, out int left, out int top, out int width, out int height);
object ans = new object(); // I also have tried IAccessible ans = null
// and Marshal's static method, but all failed.
search((IAccessible)parent, accName_, accrole_, index_,
out ans, out top, out left, out width, out height);
// the return ans is null !!!!!!!!!!!
Anyone can give some advice to improve the above code to return correct ans(search result)? Thanks.