|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
package javaTest;
import com.sun.jna.*;
/** Simple example of native library declaration and usage. */
public class HelloWorld {
// Most C libraries will just extend com.sun.jna.Library,
public interface Kernel32 extends Library {
// Method declarations, constant and structure definitions go here
Kernel32 INSTANCE = (Kernel32)Native.loadLibrary("kernel32", Kernel32.class);
// Optional: wraps every call to the native library in a synchronized block, limiting native calls to one at a time
Kernel32 SYNC_INSTANCE = (Kernel32)Native.synchronizedLibrary(INSTANCE);
public static class SYSTEMTIME extends Structure {
public short wYear;
public short wMonth;
public short wDayOfWeek;
public short wDay;
public short wHour;
public short wMinute;
public short wSecond;
public short wMilliseconds;
}
void GetSystemTime(SYSTEMTIME result);
}
public static void main(String[] args) {
Kernel32 lib = Kernel32.INSTANCE;
Kernel32.SYSTEMTIME time = new Kernel32.SYSTEMTIME();
lib.GetSystemTime(time);
System.out.println("Today's integer value is " + time.wDay + '/' + time.wMonth + '/' + time.wYear);
}
}
|
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
package javaTest;
import com.sun.jna.*;
/** Simple example of native library declaration and usage. */
public class HelloWorld {
// Most C libraries will just extend com.sun.jna.Library,
public interface FBSL extends Library {
// Method declarations, constant and structure definitions go here
FBSL INSTANCE = (FBSL)Native.loadLibrary("FBSL", FBSL.class);
// Optional: wraps every call to the native library in a synchronized block,
// limiting native calls to one at a time
FBSL SYNC_INSTANCE = (FBSL)Native.synchronizedLibrary(INSTANCE);
int FBSL_ExecuteScriptBuffer( String szBuffer );
}
public static void main(String[] args) {
FBSL lib = FBSL.INSTANCE;
lib.FBSL_ExecuteScriptBuffer("msgbox(Null, "Hello from FBSL!","Title",48)");
}
}
|
This post has been edited 4 times, last edit by "Gerome GUILLEMIN" (Feb 23rd 2009, 10:15pm)