Hi,
I remember trying to figure out why the VARIANT is broken, and ended up whipping together a minimum viable variant of my own. This snipped should get you started.
pointerVariant.ByValue varTmp = new pointerVariant.ByValue();
Memory variants = new Memory(childCount * varTmp.size());
result = Oleacc.INSTANCE.AccessibleChildren(accessible.getInterface(), 0, childCount, variants, received);
if (result != 0)
// Deal with err
int receivedChildren = received.getValue();
for (int i = 0; i < receivedChildren; i++) {
WinStructs.pointerVariant.ByValue v = new WinStructs.pointerVariant.ByValue(variants.share(i * size));
v.read();
if (v.vt == VT_DISPATCH) {
Pointer pointer = v.trustme;
PointerByReference dispatch = new PointerByReference(pointer);
Oleacc.IDispatch idi = PointerToIDispatch(dispatch);
PointerByReference childp = new PointerByReference();
result = idi.QueryInterface(new Guid.GUID.ByReference(IID_IAccessible), childp);
if (result == 0) {
Oleacc.IAccessible accessible1 = PointerToIAccessible(childp);
...
accessible1.Release();
} else {
// no interface, handle error somehow
}
}
if (v.vt == VT_I4) {
// Not all children have an interface
String childName = accessible.getChildName(v);
..
}
}
public static class pointerVariant extends Structure {
public short vt;
public short wReserved1;
public short wReserved2;
public short wReserved3;
public Pointer trustme;
public Pointer trustme2;
public pointerVariant() {
super();
setAlignType(Structure.ALIGN_MSVC);
}
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"vt", "wReserved1", "wReserved2", "wReserved3", "trustme", "trustme2"});
}
public static class ByValue extends pointerVariant implements
Structure.ByValue {
public ByValue(Pointer pointer) {
super(pointer);
}
public ByValue() {
super();
}
}
public pointerVariant(Pointer memory) {
super(memory);
setAlignType(Structure.ALIGN_MSVC);
}
}