Simple example of Windows native library declaration and usage in XPages


package de.eknori.c;
 
import com.sun.jna.Library;
import com.sun.jna.Native;
 
public class Beeper {
	private Kernel32 lib;
 
	public interface Kernel32 extends Library {
		// FREQUENCY is expressed in hertz and ranges from 37 to 32767
		// DURATION is expressed in milliseconds
		public boolean Beep(int FREQUENCY, int DURATION);
 
		public void Sleep(int DURATION);
	}
 
	public Beeper() {
		lib = (Kernel32) Native.loadLibrary("kernel32", Kernel32.class);
	}
 
	public void test() {
		lib.Beep(500, 500);
		lib.Sleep(500);
		lib.Beep(1000, 500);
	}
}
All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
No comments yetLogin first to comment...