I am new to JNA and I have this code that should block input by calling a DLL file in win7. But when I run this code, nothing happens. There is no compilation error, and I cannot understand why it does not block my keyboard and mouse. Please guide me.
public class BlockInput { public static void main(String[] args) { NativeLibrary lib = NativeLibrary.getInstance("user32"); Function fun = lib.getFunction("BlockInput"); System.out.println("Lib :" + lib + ".\nFun " + fun + "."); fun.invoke(new Object[]{Boolean.TRUE}); try { Thread.sleep(10000); } catch(InterruptedException ie) {} lib.dispose(); } }
EDIT: with Native.getLastError (); I found out that I am accessing the dll file. I get error 5 (Access denied). Is there any possible way to gain access so that I can make it work?
source share