var wRoot = new ctypes.unsigned_long();
var wParent = new ctypes.unsigned_long();
var wChild = new ctypes.unsigned_long.ptr();
var nChildren = new ctypes.unsigned_int();
var rez = XQueryTree(_disp, w, wRoot.address(), wParent.address(), wChild.address(), nChildren.address())
if(rez != 0) { //can probably test this against `None` instead of `0`
var nChildrenCasted = ctypes.cast(nChildren, ctypes.unsigned_int).value;
for(var i=0; i<nChildrenCasted; i++) {
searchForPidStartingAtWindow(wChild[i]);
}
} else {
console.warn('this window has no children, rez:', rez);
}
我成功地获得了nChildrenCasted
它的94。
但是我无法访问wChild
个元素,它应该是一个数组
问题在于:searchForPidStartingAtWindow(wChild[i]);
如何传递wChild[i]
?
我试过了:
var wChildCasted = ctypes.cast(wChild, ctypes.unsigned_long).contents;
console.log('wChildCasted:', wChildCasted);
我很确定它沿着这些路线,但我无法弄清楚
完整代码,可以从便笺簿复制粘贴并运行:
答案 0 :(得分:3)
您需要从原始指针类型转换为ArrayType指针:
var wChildCasted = ctypes.cast(wChild, ctypes.ArrayType(ctypes.unsigned_long, nChildrenCasted).ptr).contents;