I play with these two native win32 features:
[DllImport( "oleacc.dll" )] public static extern int AccessibleObjectFromWindow( IntPtr hwnd, int dwObjectID, ref Guid refID, ref Accessibility.IAccessible ppvObject ); [DllImport( "oleacc.dll" )] public static extern uint AccessibleChildren( Accessibility.IAccessible paccContainer, int iChildStart, int cChildren, [Out] object[] rgvarChildren, out int pcObtained );
And it's hard for me to understand if I need / I need to call Marshal.ReleaseComObject for any of the returned objects. I would appreciate it if someone could enlighten me on this topic! Here's a usage example:
Accessibility.IAccessible test( int hWnd, string accessName ) { Guid guidCOM = new Guid( 0x618736E0, 0x3C3D, 0x11CF, 0x81, 0xC, 0x0, 0xAA, 0x0, 0x38, 0x9B, 0x71 ); Accessibility.IAccessible a = null; AccessibleObjectFromWindow( new IntPtr( hWnd ), -4, ref guidCOM, ref a ); object[] children = new object[a.accChildCount]; int z; AccessibleChildren( a, 0, children.Length, children, out z ); foreach ( Accessibility.IAccessible a2 in children ) try { if ( a2.get_accName( 0 ) == accessName ) return a2; } catch { } return null; }
Dan bystrΓΆm
source share