I'm experimenting with JNA, and this is the first program I try to run. I copied it from the reference, but, when i run it, he finds 412 windows ... and I'm quite sure I've not that many window opened right now :) Can please someone explain me the behaviour of the program?
import com.sun.jna.Pointer;
import com.sun.jna.win32.StdCallLibrary.StdCallCallback;
import com.sun.jna.Native;
import com.sun.jna.win32.StdCallLibrary;
public class Main {
// Equivalent JNA mappings
public interface User32 extends StdCallLibrary {
User32 INSTANCE = (User32) Native.loadLibrary("user32", User32.class);
interface WNDENUMPROC extends StdCallCallback {
boolean callback(Pointer hWnd, Pointer arg);
}
boolean EnumWindows(WNDENUMPROC lpEnumFunc, Pointer arg);
}
public static void main(String[] args) {
User32 user32 = User32.INSTANCE;
user32.EnumWindows(new User32.WNDENUMPROC() {
int count;
public boolean callback(Pointer hWnd, Pointer userData) {
System.out.println("Found window " + hWnd + ", total " + ++count);
return true;
}
}, null);
}
}