Any idea how to get this API to work?

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
 
M

Mattias Sjögren

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
 
C

codercode

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?
 
M

Mattias Sjögren

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
 
C

codercode

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!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top