public static User32 USER32_INSTANCE = (User32) Native.loadLibrary(\"user32\", User32.class);
user32 = USER32_INSTANCE;
user32.EnumWindows((hWn
After opening a handle to a process with OpenProcess, you need to close the process handle with CloseHandle. Remember that OpenProcess returns a Handle
, not a Pointer
.
Kernel32.INSTANCE.CloseHandle(process);
Note also that JNA provides a pretty in-depth mapping of the Windows API out of the box in the net.java.dev.jna-platform package (I think?)