Any idea how to get this API to work?

  • Thread starter Thread starter codercode
  • Start date Start date
C

codercode

Private Declare Function AccessibleChildren Lib "oleacc" (ByVal
paccContainer As IAccessible, _
ByVal iChildStart As Integer, _
ByVal cChildren As Integer, _
ByVal rgvarChildren() As Object, _
ByVal pcObtained As Integer) As UInteger

Dim iTMP As Accessibility.IAccessible
Dim lngTMP2 As Integer
iTMP = lngTMP
Dim lngCount As Integer
lngCount = iTMP.accChildCount
Dim Children(lngCount - 1) As Object

Call AccessibleChildren(iTMP, 0, (lngCount - 1), Children(0), lngTMP2)

I can't get the 'rgvarChildren' parameter correct.



My code's translated from the following C# code:

[DllImport("Oleacc.dll")]
public static extern int AccessibleChildren(
Accessibility.IAccessible paccContainer,
int iChildStart,
int cChildren,
[Out] object[] rgvarChildren,
out int pcObtained);

int _ChildCount = IACurrent.accChildCount;
object[] _Children = new object[_ChildCount];
int _out;

AccessibleChildren(IACurrent,0,_ChildCount-1,_Children,out _out);


Thanks in advance
 
Private Declare Function AccessibleChildren Lib "oleacc" (ByVal
paccContainer As IAccessible, _
ByVal iChildStart As Integer, _
ByVal cChildren As Integer, _
ByVal rgvarChildren() As Object, _
ByVal pcObtained As Integer) As UInteger

Dim iTMP As Accessibility.IAccessible
Dim lngTMP2 As Integer
iTMP = lngTMP
Dim lngCount As Integer
lngCount = iTMP.accChildCount
Dim Children(lngCount - 1) As Object

Call AccessibleChildren(iTMP, 0, (lngCount - 1), Children(0), lngTMP2)

I can't get the 'rgvarChildren' parameter correct.

Pass in Children rather than Children(0).

You should also change the pcObtained parameter to ByRef.


Mattias
 
Pass in Children rather than Children(0).

You should also change the pcObtained parameter to ByRef.

Mattias

It still doesn't work on VB 2005. An empty Children is returned.
However, it does work on VB6 by declaring Children as a Variant. Any
ideas?
 
It still doesn't work on VB 2005. An empty Children is returned.
However, it does work on VB6 by declaring Children as a Variant. Any
ideas?

Try declaring the parameter like this then

<[Out], MarshalAs(UnmanagedType.LPArray,
ArraySubType:=UnmanagedType.Struct)> ByVal rgvarChildren() As Object


Mattias
 
It still doesn't work on VB 2005. An empty Children is returned.
However, it does work on VB6 by declaring Children as a Variant. Any
ideas?

Try declaring the parameter like this then

<[Out], MarshalAs(UnmanagedType.LPArray,
ArraySubType:=UnmanagedType.Struct)> ByVal rgvarChildren() As Object

Mattias

Thanks a lot Mattias. It's working perfectly!! Thank you!!
 
Back
Top